Support

Account

Home Forums General Issues Multiple checkbox queries?

Helping

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 ),
    );	
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Multiple checkbox queries?’ is closed to new replies.