
You’d think that this was a core WooCommerce setting – it’s not.
In fact, from the WordPress “Customizer“, you can set the product category page display to “Show products” only, “Show subcategories” only, or “Show subcategories and products” (see screenshot below). But these 3 options, in my opinion, could and should do much better.
For example, if you assign a product “ABC” to a parent category “X“, and a product “DEF” to a child category “X->Y“, and if you choose “Show products“, the parent category page will show both “ABC” and “DEF” products, while there should only be 1.
If you select “Show subcategories“, the same page will only have the link to the subcategory, but the product belonging to the parent category, “ABC“, won’t be visible, which doesn’t make sense.
If, even worse, you pick “Show subcategories and products“, the parent category page will display the subcategory link, as well as both products “ABC” and “DEF“, which once again is a bit weird.
Let’s fix this with a simple snippet – enjoy!
Continue reading WooCommerce: Hide SubCategory Products On Product Category Pages