0
votes

When a user visits my WooCommerce Category pages, I want the sidebar to display a list of categories that varies depending on what the current category is.

There is a default "WooCommerce Category Widget", that shows all product categories on the website. However, I don't want to show all these.

I simply want to show either:

A) If the current category is a parent category, the list of categories must show the children categories only

or

B) If the current category is a child category, the list of categories must show the sibling categories only (sibling = categories with the same parent)

Example:

Parent Category 1 - Child Category 1A - Child Category 1B Parent Category 2 - Child Category 2A - Child Category 2B

If the user visits Parent Category 1 in the example above, the sidebar should show this:

  • Child Category 1A
  • Child Category 1B

I've tried using the default WooCommerce Category Widget.

I've also found this article from 2014, that describes the exact same problem: http://www.kablooeystudios.com/woocommerce-sidebar-parents-or-children/

The article provides af solution, but when I implement the code, I can't get it to work. Perhaps I haven't put the code the right place - and if so, where should I put it? (I've tried putting it in my child theme's functions.php.

1

1 Answers

0
votes

The link you have provided, where the instructions are, I have not checked the instructions in detail but I would follow it with care. That article is more than 4 years old! What version woo you have on your site?