Answer the question
In order to leave comments, you need to log in
WooCommerce Display subcategories
Guys, tell me please how can I display only subcategories of a certain category?
There is this code:
<?php
$args = array(
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids,
'parent' => 0
);
$product_categories = get_terms( 'product_cat', $args );
foreach( $product_categories as $cat ) {
echo '<div class="nav_pg_holder"><a class="nav_pg">'. $cat->name . '</a><img src="http://test1.ru/wp-content/themes/lavare/img/krestik.png" class="krestik" alt=""></div>';
}
?>
Answer the question
In order to leave comments, you need to log in
the child_of parameter in the arguments array.
you don't have it. but parent is present.
parent can be safely removed from the list, instead put child_of
in it, put the ID of the desired term.
the whole tree of his descendants will return.
read the details in the instructions for the method wp-kama.ru/function/get_terms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question