Home › Forums › ACF PRO › True/False – No Value for False › Reply To: True/False – No Value for False
I had multiple things going on but in the end this was the code that worked for me. Feel free to dissect out of this what you need. In my case the client wanted the featured projects to be at the top and then added the criteria that they would also like to exclude some posts from displaying in the list but still wanted them accessible as single posts. With this my featured posts were at the top and my excluded posts did not display. And if a user clicked both boxes it defaulted to not display.
'post_type' => 'work',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'featured_project',
'orderby' => 'meta_value date',
'order' => 'DSC',
'meta_query' => array(
'relation' => 'OR',
'exclude_posts' => array(
'relation' => 'OR',
array(
'key' => 'exclude_project',
'compare' => '!=',
'value' => '1'
),
array(
'key' => 'exclude_project',
'type' => 'BOOLEAN',
'value' => false
),
array(
'key' => 'exclude_project',
'compare' => 'NOT EXISTS'
),
),
'featured_posts' => array(
'relation' => 'AND',
array(
'key' => 'featured_project',
'value' => '1',
'compare' => '='
),
array(
'key' => 'exclude_project',
'compare' => '!=',
'value' => '1'
),
),
),
);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.