M
M
Mikhail Ivanov2017-06-15 11:52:09
WordPress
Mikhail Ivanov, 2017-06-15 11:52:09

How to display subcategories in the sidebar on the product page?

There is a page for more than 6 categories, let's say I went to accessories, and the sidebar with subcategories of accessories is displayed on the page, tell me where to read

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mr_Edward, 2017-06-15
@Mr_Edward

We make it a widget , as expected. Internally check the current page for is_category() . If yes, then we start to wool where we are (current category id):

$category = get_queried_object();
echo $category->term_id;

After that, we make a selection using get_terms() , where we check the parent of the subcategory for a match with the current rubric ( parent argument ). Naturally, if the rubric does not have a parent, then there is no point in making an extra request, keep this in mind too.

M
Mikhail Ivanov, 2017-06-15
@mishaweb

I solved the problem differently, installed the visual composer plugin, did not display subcategories in the sitebar, displayed them on the page of each category suits me.
If someone wants to display in the sitebar, then I think that you can create a page, display categories or subcategories on it through the visual composer, all the pages that you have created are like categories, make a menu out of it and add it to the sitebar as usual through an arbitrary menu. In general, as I can explain, if that guys write who will have such a task, I will explain if something is not clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question