By default, empty WooCommerce product categories (i.e. categories which have no published products) will not display on your Shop page.
This makes a lot of sense and avoids that customers land on empty pages… BUT sometimes you might have different needs and require that users still see these categories when the shop display is set to “Show Categories”.
Thankfully there is a quick one-line fix that you can copy / paste in your functions.php to show empty categories… enjoy!
PHP Snippet: Show Empty WooCommerce Product Categories
/**
* @snippet Show Empty Categories @ Shop Page
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 5
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );
PHP Snippet (Storefront Theme): Show Empty WooCommerce Product Categories @ Homepage
/**
* @snippet Show Empty Categories @ Homepage
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 5
* @community https://businessbloomer.com/club/
*/
add_filter( 'storefront_product_categories_shortcode_args', 'bblomer_storefront_homepage_show_empty_cats' );
function bblomer_storefront_homepage_show_empty_cats( $args ) {
$args['hide_empty'] = 0;
return $args;
}
Hi,
This doesnt work for me when using a shortcode. It works on the woocommerce default storefront page but I want to show all the product categories using a shortcode on a custom page using:
Any ideas? Thanks in advance.
Hi Leanne, you should use the “hide_empty” shortcode parameter, and set that to 0
Perfect, thanks so much.
This doesn’t work in Woocommerce 5
Tried on a different theme already?