Support

Account

Home Forums General Issues Help with query posts filtered by multiple field values Reply To: Help with query posts filtered by multiple field values

  • ahhhh!

    Actually your code should work but you need to change it to this:

    
    <?php 
    $selected = get_field('q_and_a_category_select');
    $args=array(
    	'post_type' => 'q-and-a',
    	'q_and_a_category' => "$selected" //the slug for the custom taxonomy term
    	);
    	$my_query = new WP_Query($args);
    	if( $my_query->have_posts() ) {
    		while ($my_query->have_posts()) : $my_query->the_post(); ?>
    	
    		<?php the_title(); ?>
    
    	<?php endwhile; }?>
    
    <?php wp_reset_query(); ?>
    
    

    you could put the get_field directly in the array but I think this looks more structured 🙂