categories - Display all subcategories for a product category in woocommerce

admin2025-06-03  2

Is there a way to add a shortcode to a page, in order for that to display the subcategories of a category? (not the products themselves)

I know that you can configure Woocommerce to display it, but I need to have it on a page, so that I can hide it via UAM plugin.

I am aware of the shortcode:

[product_categories number="12" parent="0"]

But that displays only the top categories. I need the child categories of one top category.

Is there a way to add a shortcode to a page, in order for that to display the subcategories of a category? (not the products themselves)

I know that you can configure Woocommerce to display it, but I need to have it on a page, so that I can hide it via UAM plugin.

I am aware of the shortcode:

[product_categories number="12" parent="0"]

But that displays only the top categories. I need the child categories of one top category.

Share Improve this question edited Aug 8, 2013 at 13:25 GhostToast 4,6063 gold badges29 silver badges44 bronze badges asked Aug 8, 2013 at 12:56 Sofus AlbertsenSofus Albertsen 111 gold badge1 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 3

That's easy. Just use the same shortcode and in the parent attribute, place the ID of the parent category. You'll get out its sub-categories as a result:

[product_categories number="12" parent="57"]

You could easily display the category widget from WooCommerce in a page template using :

the_widget('WC_Widget_Product_Categories'); 

The code with parameters can be find in woocommerce\classes\widgets\class-wc-widget-product-categories.php

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748965480a315218.html

最新回复(0)