Horhe Garcia
Horhe Garcia

Reputation: 902

Show empty subcategories in WooCommerce 3

I tried this code, it shows root categories, but subcategories without products are still hidden.

function hide_empty_categories ( $hide_empty ) {
    $hide_empty  =  FALSE;
    // You can add other logic here too
    return $hide_empty;
}
add_filter( 'woocommerce_product_subcategories_hide_empty', 'hide_empty_categories', 10, 1 );

Upvotes: 1

Views: 1559

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 253784

This problem can come from some other customizations you have added yourself, some wrong settings, your main theme customizations or some third party plugin.

Something else is altering your the product categories loop as your code correctly enables to show empty product subcategories in Woocommerce and it's the right hook to be used.

It can be simplified with this simple line of code too:

add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Upvotes: 1

Related Questions