<?php
$term = get_queried_object();
$args = array(
'post_type' => 'products',
'product-categories' => $term->slug
);
$query = new WP_Query( $args );
echo $term->name;
if ($query->have_posts()) {
// output the term name in a heading tag
echo'<h2>Animals in the ' . $term->name . ' Family</h2>';
// output the post titles in a list
echo '<ul>';
// Start the Loop
while ( $query->have_posts() ) : $query->the_post(); ?>
<li class="animal-listing" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile;
echo '</ul>';
}
wp_reset_postdata();
?>