Support

Account

Home Forums General Issues Multi Select – Get all choices for Query Args Reply To: Multi Select – Get all choices for Query Args

  • Does something like the below work:

    $event_cat_ids = array( 37, 47 );
    
    $args = array(
    		'post_type' 		=> 'event',
    		'post_status'		=> 'publish',
    		'posts_per_page'	=> -1, // show all posts.
    		'order'				=> 'DESC',
    );
    			
    $args['tax_query'] = array(
    	'relation' 		=> 'OR', 
    
    	array(
    		'taxonomy'	=> 'event_category',
    		'field'		=> 'term_id',
    		'terms'		=> $event_cat_ids
    	),			
    		
    );
    
    $query = new WP_Query( $args );
    if( $query->have_posts() ) : 
    
    	while( $query->have_posts() ): $query->the_post(); ?>
    	<h2><?php the_title(); ?></h2>
    	<?php endwhile;  wp_reset_postdata();
    
    endif;

    Replace the values in the array to some cat IDs just to test the code.

    If that works, you then need to adjust to suit your needs i.e. use your field value.