<?php | |
// How to only get children of the current term | |
?> | |
<div class="category-list"> | |
<?php | |
$term_id = get_queried_object()->term_id; | |
$term = get_term($term_id, 'product_cat' ); | |
$args = array( | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => false, | |
'child_of' => $term->term_id, | |
'parent' => $term->term_id | |
); | |
$sub_terms = get_terms( 'product_cat', $args); | |
//print_rr($subproducts); | |
foreach ($sub_terms as $term) { ?> | |
<li> <a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?><?php /*echo "<span class='count'>" . $subproduct->count . "</span>"; */ ?></a></li> | |
<?php } ?> | |
</div> |
How to display only children of the current term
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Have Questions? I can help! Get Started
Leave a Reply