L
L
ligisayan2016-02-09 10:46:02
Electronic commerce
ligisayan, 2016-02-09 10:46:02

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

2 answer(s)
Z
Zhainar, 2016-02-09
@zhainar

get_terms('product_cat');
then filter through the condition
if( $cat->parent ) { ... }
wp-kama.ru/function/get_terms

L
ligisayan, 2016-02-09
@ligisayan

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 question

Ask a Question

731 491 924 answers to any question