Reputation: 1488
Woocommerce generally displays only the categories with products on the Shop page. I would like to display all the categories(except Uncategorized) in the Shop Page even if it's empty.
The below displays all the categories including Uncategorized. Is there a way to exclude Uncategorized from that?
add_filter( 'woocommerce_product_subcategories_hide_empty', 'show_empty_categories', 10, 1 );
function show_empty_categories ( $show_empty ) {
$show_empty = true;
return $show_empty;
}
Upvotes: 3
Views: 1124
Reputation: 29624
Change the args in the following way
https://github.com/woocommerce/woocommerce/blob/master/includes/wc-template-functions.php#L2479
function my_product_subcategories_arg( $args ) {
$uncategorized = get_option( 'default_product_cat' );
$args['exclude'] = $uncategorized;
$args['hide_empty'] = 0;
return $args;
}
add_filter( 'woocommerce_product_subcategories_args', 'my_product_subcategories_arg', 10, 1 );
Upvotes: 1