I love that in L&L the condition can be separated from the loop and it’s possible to create a complex query. I’ll use it extensively to display only certain posts that have particular ACF field values.
If I manage to understand how to use it…
Let’s say that I have a custom post type named
For each Car post type, I have an ACF field named
Manufacturer which is a Radio Button field.
For each Car Manufacturer, I have multiple choices:
On my first attempt, I’ll try to use the
Logic tag to define a single condition (but I will have to define multiple ones). I want to display only cars from Ford.
So I write the following code:
<Set logic="is_electric" any=true> <If acf_radio="manufacturer" field="Ford">true<Else />false</If> </Set> <Loop type="cars"> <If logic="is_electric"> <Field title /><br /> </If> </Loop>
This code generates nothing. I’m assuming it’s a syntax error, but I can’t figure which one.
I tried all the following variants, which either ignore my condition or generate no results as well:
<If acf_radio="manufacturer" value="Ford">true<Else />false</If>
<If acf_radio="manufacturer" field="Ford">true<Else />false</If>
<If field="manufacturer" value="Ford">true<Else />false</If>
As soon as I figure this out, I’ll have to add a second condition so that I can display cars from either Ford or Toyota but not Mercedes.
Thank you and sorry if I missed something obvious.