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.
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.