Answer the question
In order to leave comments, you need to log in
How to show all child subcategories of product categories?
Hello! There is a need to display all all categories of goods, while excluding the parent ones. For this purpose, I use the wp_list_categories() function
and the 'child_of ' attribute, but it only allows you to make such a conclusion for one category - but how to do it for all?
Answer the question
In order to leave comments, you need to log in
get_terms('product_cat');
then filter through the condition
if( $cat->parent ) { ... }
wp-kama.ru/function/get_terms
I decided in a simple way - for each necessary parent, display its child, and after wp_list_categories :
$argsuments = array(
'taxonomy' => 'product_cat',
'child_of' => 3416,
'title_li' => '',
'depth' => 4,
'hide_empty' => 1
);
wp_list_categories( $argsuments );
$argsuments['child_of'] = 3576;
wp_list_categories( $argsuments );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question