NO BUG: Condition not working for ACF true/false

Browser: Chrome
OS: macOS

I want to set a condition for products to show on the homepage.
Therefore i used a ACF true/false field.
The field show the value 1 (with the dynamic field “acf_auf_homepage_zeigen:value”) or the label “true” (with the dynamic field “acf_auf_homepage_zeigen”).

The condition doesn`t work in any way - i tried different ways like:

show if == 1
show if == TRUE
show if != FALSE
show if >= 1
show if != 0
show if != Null



Hi Andreas,
Thanks so much for your report!

The condition on the loop item itself does not work (only for elements within the loop) - in your case a meta query would be the right choice.

The acf true/false field returns the label by default, i.e. True or False. However, you can also have the value returned by using the :value filter: {your_truefalse_field:value}.

1 is returned if true, if false, the value remains empty. You can see this if you output the field inside the loop in e.g. a basic text field.

For the meta query you have several possibilities:

  1. Shows all posts that have your acf meta key (true)

  2. Shows all posts without the meta key (false)

  3. Shows all posts with a meta key value of 1 (true)

Best regards,
timmse

1 Like

thank you very much timmse.
i tried your solution with the meta key “acf_auf_homepage_zeigen” and “{acf_auf_homepage_zeigen}” in combination with Value “1” but i couldn´t make it work.
The same for the other solution with “compare” and “exists”.
Nothing will show up and 2 of 3 products have true/1 as value.

I used the meta query on the same element (card) like the dynamic query.


The meta key within the meta query should be auf_homepage_zeigen, should not contain curly braces and should not be prefixed with acf_ (as in my screenshots).

thx, now it works - I really appreciate it