Website Building » WooCommerce » How Do I Hide Category Count in WooCommerce?

How Do I Hide Category Count in WooCommerce?

Last updated on January 17, 2023 @ 12:17 pm

If you’re running a WooCommerce store, you might be wondering how to hide the category count from showing up next to your category names. By default, WooCommerce will show the number of products that are in each category, but this can be a bit misleading if some of your categories have a lot of products and others have very few. In this article, we’ll show you how to hide the category count in WooCommerce.

The first thing you need to do is edit the functions.php file of your child theme. If you’re not using a child theme, you can create one by following our guide on how to create a child theme in WooCommerce. Once you’ve done that, add the following code to your functions.php file:


// Hide category count
add_filter( 'woocommerce_subcategory_count_html', '__return_false' );

This code will remove the default category count that appears next to each category name on your shop page. If you want to take things one step further and also remove the count from showing up in your category widget, you can add this code:


// Hide category count in widgets
add_filter( 'woocommerce_category_widget_args', 'my_hide_category_count' );
function my_hide_category_count( $args ) {$args['show_count'] = false;
return $args;} 

Conclusion:

In conclusion, hiding the category count in WooCommerce is fairly simple and only requires adding a few lines of code to your functions.php file. This can be helpful if you want to avoid confusion for customers who might see a high number of products in one category and assume that all categories have a similar number of products.

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.