WooCommerce includes a widget that allows a list or dropdown of product categories in the sidebar. This widget allows you to list categories and sub categories in the sidebar, with many options, to hide empty categories, only show children of current category and show hierarchy, show product counts.
However, one important feature it does not have, is to hide other categories and only show current category and sub categories.
This can be achieved by some clever css code:
.product-categories > .cat-item{display:none;} .product-categories .cat-parent{display:inline!important;}
hope that helps.
IT doesn’t work. What is “>” in the code? CSS doesn’t accept this.
it should accept > . it is to target the attribute.
Hi Ali,
I tried adding ur css and the widget still shows all the categories. Im modifying the single product page, and would like to see only the categories to which the product belongs.
Thanks,
Victor
Please make sure your css is not being overridden by any other css code in theme of child theme and you are looking at fresh copy of css file. Soemtimes, cached copy doesn’t show updated result.
It had worked for me.