0

I have a a custom taxonomy called "products_cat" this custom taxonomy has different terms as parent categories: "Electronics", "Computer", "Home Appliances", etc. And then under each of those terms I have more sub-terms like under "Electronics" for example I have "TV", "Audio", "Home Theaters", "MP3",etc.

So the thing I'm trying to do is to have within the taxonomy-product_cat.php a code that display the current chosen Taxonomy (suppose Electronics) and then have the titles of all children and the products under each one of those.

Thanks.

Jaypee
  • 1,272
  • 5
  • 17
  • 37

1 Answers1

0

Try getting all the term children of the current term you are displaying. Then looping through each of those and pulling the posts for each term. You could do something like the below:

<?php
$taxonomies = get_term_children( $id, 'custom_cat');
foreach($taxonomies as $tax){
    $term = get_term_by( 'id', $child, $taxonomy_name );
    get_posts(array('cat'=>$term['id']));
}
?> 
Hugh Downer
  • 106
  • 6