Show Empty Product Categories in WooCommerce

3d Animation

By default, WooCommerce hides empty product categories and sub-product categories. Occasionally, it’s useful to display all the available product categories, especially when building a new WooCommerce site. Here’s a simple snippet to unhide them!


/** Show empty product categories */

add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );
add_filter( 'woocommerce_product_categories_hide_empty', '__return_false' );

To also display empty sub-sub categories, you may need to add this extra code too.


/** Show empty product  sub sub categories */

add_filter( 'get_terms_args', function( $args, $taxonomies ) {

    if ( in_array( 'product_cat', (array) $taxonomies, true ) ) {
        $args['hide_empty'] = false;
        $args['pad_counts'] = true; // important for grandchildren
    }

    return $args;

}, 999, 2 );