Listing all custom posts having a specific taxonomy whatever the terms

I’d like to get a list of all the custom posts that belong to a specific taxonomy.

I’ve tried many things including this code, but I get a list of all the posts in the ‘members’ cpt, and not just posts associated to the ‘producers’ taxonomy. How can I get it work ?

<?php
$args = array(
‘post_type’ => ‘members’,
‘posts_per_page’ => -1,
‘tax_query’ => array(
‘taxonomy’ => ‘producers’
),
);
$the_query = new WP_Query($args);
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<li class=”producers” id=”post-<?php the_ID(); ?>”>
<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>
</li>
<?php
endwhile;
?>

Read more here:: Listing all custom posts having a specific taxonomy whatever the terms

Leave a Reply

Your email address will not be published. Required fields are marked *