Answer the question
In order to leave comments, you need to log in
How to display subcategories of the 2nd level?
There is a 3-level nesting for the categories
Clothes and shoes:
-Men:
-Clothes
-Shoes
-Women:
-Clothes
-Shoes
In this case, men and women
I got the current category like this:
$current_cat = get_queried_object();
$parent_cat = $current_cat->term_id;
$children_categories = get_term_children( $parent_cat, 'product_cat' );
if ( $children_categories ) {
foreach($children_categories as $child_category) {
$term = get_term( $child_category, 'product_cat' );
print_r($term);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question