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