Home › Forums › Backend Issues (wp-admin) › WP Query – Multiple values in ACF Checkbox › Reply To: WP Query – Multiple values in ACF Checkbox
Thanks John,
I get it – and here’s what I’ve written:
$past_args = array(
'post_type' => 'event',
'meta_query' => array(
'relation' => 'AND',
array(
'relation' => 'OR',
// check to see if end date has been set
array(
'key' => 'end_date',
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
'value' => array($date_1, $date_2),
),
// if no end date has been set use event/start date
array(
'key' => 'start_date',
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
'value' => array($date_1, $date_2),
)
),
array(
'relation' => 'OR',
// check event is not cancelled
array(
'key' => 'status',
'value' => '"Cancelled"',
'compare' => 'NOT LIKE'
),
// check event is not excluded from past events
array(
'key' => 'status',
'value' => '"Exclude Past"',
'compare' => 'NOT LIKE'
)
)
),
'orderby' => 'meta_value_num',
'order' => 'DESC',
'nopaging' => false,
'posts_per_page' => '4'
);
BUT – despite there clearly being an OR
relation for the two queries on the status
field, it is behaving like an AND
relation. The event is only left out of the query if both boxes are checked.
Any idea why this would be? Might it have something to do with being inside an AND
relation? The OR
relation on the date clause is working fine. I’ve pulled this right back to individual nested queries to try and isolate the problem but it has really stumped me.
Thanks.
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.