I am attempting to display all the posts that tagged to specific terms in WordPress, at the moment it’s displaying all my posts in the custom post type rather than the posts tagged to each term. I have a file called taxonomy-clientType.php and then here is the code I use to try fill my WP_Query with the correct posts
$taxonomy = 'clientType';
$tax_terms = get_terms($taxonomy);
$term = get_queried_object();
// Define the query
$args = array(
'post_type' => 'clients',
'tax_query' => array(
'taxonomy' => 'clientType',
'field' => 'slug',
'terms' => $term->name
)
);
$query = new WP_Query( $args );
Can anyone see where I am going wrong?
Thanks
Try: