I'm trying to make a list of all the posts classified under one term for a custom taxonomy.
I have created a custom post type called "testimonial" with a custom taxonomy of "testimonial categories". with in testimonial categories I have created the terms "colleagues" and "clients". I am trying to create too archive pages. One that will list all of the posts under colleagues and the other list all posts under clients. I have created the archive pages taxonomy-testimonial_categories-clients.php and taxonomy-testimonial_categories-colleagues.php. And can creat a list of all post under the cpt testimonials but can't filter it by the terms Colleagues or clients.
After research on wordpress.org I believe that using tax_query with new WP_Query is the way to go. Here is the code I'm working with now.
<?php
$args = array(
'post_type' => 'testimonial',
'tax_query' => array(
array(
'taxonomy' => 'testimonial_categories',
'field' => 'slug',
'terms' => 'colleagues'
)
)
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<span class="frame small alignleft">
<?php the_post_thumbnail(thumbnail); ?>
<span>
<div class="test-content">
<?php the_content(); ?>
</div>
<?php endwhile; ?>