Home › Forums › General Issues › Multiple checkbox queries?
Can you query multiple values in the checkbox query?
$args = array(
'child_of' => '7',
'post__not_in' => array(2228),
'meta_query' => array(
array(
'key' => 'select_office_location',
'value' =>'"Austin"',
'compare' => 'LIKE',
)
),
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'meta_value',
'order' => 'ASC',
'posts_per_page' => '20',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
);
This returns page/post with Austin as the custom field checkbox.
How can return Austin results then Houston after that in what seems like one loop?
$args = array(
'child_of' => '7',
'post__not_in' => array(2228),
'meta_query' => array(
array(
'key' => 'select_office_location',
'value' =>'"Austin"',
'compare' => 'BETWEEN',
),
array(
'key' => 'select_office_location',
'value' => '"Houston"',
'compare' => 'LIKE'
)
),
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'meta_value',
'order' => 'ASC',
'posts_per_page' => '20',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
);
this returned no results.
I got this to work but now what I need is results for Austin to show first then results for Houston.
$args = array(
'child_of' => '7',
'post__not_in' => array(2228),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'select_office_location',
'value' => '"Austin"',
'compare' => 'LIKE'
),
array(
'key' => 'select_office_location',
'value' => '"Houston"',
'compare' => 'LIKE'
)
),
'post_type' => 'page',
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'meta_value',
'posts_per_page' => '20',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
);
The topic ‘Multiple checkbox queries?’ is closed to new replies.
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.