Answer the question
In order to leave comments, you need to log in
How to display subcategories of products on the category page?
Hello. Please tell someone who is not very knowledgeable in PHP.
There are several pages, let's say "Category1" "Category2", etc. In each such category there are several "Subcategories", and within the "Subcategories" there is already a product.
The essence of the problem is this, it is necessary to display certain "Subcategories" on the "Category1" page.
I tried to use the shortcodes that I found, but it turns out that it displays only PRODUCTS FROM SUBCATEGORIES and/or SUBCATEGORIES and PRODUCTS, but only Subcategories does not display.
Help me please? Thanks in advance
Answer the question
In order to leave comments, you need to log in
Woo can do it himself. Go to the category and set the
UPD display type
wp-kama.ru/function/get_terms
A simple example. display child categories for the category with id 30
<ul>
<?php
$terms = get_terms( 'product_cat', array( 'child_of' => 30, ) );
foreach ($terms as $term) {
echo '<li><a href="'.get_term_link($term,'product_cat').'">'.$term->name.'</a></li>';
} ?>
</ul>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question