Query based on ACF True/False

I want to ask something about ACF+Query.

  1. I have a True/False ACF for a CPT (Products). In my query template block (Sliders), I want to show the Products that have “True” checked only. How do I do so? I try to avoid creating too many taxonomies for a CPT. So, I chose ACF Field instead.

  2. Similar to 1. I have some items that have True checked. How do I exclude the CPTs that are True?

Any ideas?
Thanks in advance!

Hey @jornes ,

if I get you right, you would want to create a meta_query, something like this:

  1. Meta Key: Add the name of your ACF-Field
  2. Meta Compare: Add the comparison type
  3. Meta Value: As you have a true/false field you would need to add a type of “boolean” and add true or false for the value (get’s converted to 0 and 1 automatically)

To exclude them you would just have to inverse the query, either selecting those who are false or change the compare type to !=



Hi @Wolfgang

It works. Thank you very much for such detailed steps!
Anyway, I noticed that “Items Per Page” didn’t work after I did this query. Any ideas?

@Louis Is that a bug or something that can be improved? I inserted 15 items per page, but it only shows 7 on the front end.

I have more than 30 CPTs (products) now.

Actually, I don’t understand what the boolean and other values are for. No idea at all. :grinning: