0
votes

I'm trying to display a list of woocommerce product subcategories, including any sub-sub-categories (children of) - how can I modify the following code to do this - which displays a list of categories from cat ID 51:

$wcatTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'parent' => 51, 'hierarchical' => 1 )); 
    foreach($wcatTerms as $wcatTerm) : 
    $wthumbnail_id = get_woocommerce_term_meta( $wcatTerm->term_id, 'thumbnail_id', true );
    $wimage = wp_get_attachment_url( $wthumbnail_id );
?>
<a class="cat-items" href="<?php echo get_term_link( $wcatTerm->slug, $wcatTerm->taxonomy ); ?>"><h3><?php echo $wcatTerm->name; ?></h3></a>
1
Thanks but I couldn't get that solution to work for me - the one I'm using works but doesn't fetch the sub-sub catorgoriesFento

1 Answers

0
votes

To get the children of each you can, assign the ID of the current category in the foreach loop to a variable, then use get_terms within the foreach using a similar query as the one you used above, but change the 'parent' to the variable attached to the ID