Woocommerce Remove Product Count

How to Hide Category Product Count in WooCommerce

By default WooCommerce shows Product Count Numbers just next to the category name in WooCommerce categories list.

Sometimes that’s not something you want to show to your customers. You may have too much products and the huge number looks ugly, or too small amount of products and you don’t want to reveal that.

Sometimes it just doesn’t look right, especially if you are using a free theme with simple design. Frankly speaking, even with the default WooCommerce theme Storefront, things doesn’t look good with it’s yellow marking.

[wc_box color=”primary” text_align=”left” margin_top=”” margin_bottom=”” class=”has-shadow”]Woocommerce Categories Product Count[/wc_box]

To make things even worse, on a store with a large inventory (hundreds and thousands of items) the product count can easily slow down your loading speed.

Today we are going to show you how to hide the Product Count Numbers with a single line code snippet.

Preparation

Before we start, make sure you have a child-theme prepared for your WordPress theme. If you’re an Althemist themes user, you can download a free starter child-theme here. You should never customize the code in your parent theme as this will be wiped entirely every time when you update it.

Alternatively, you may use a plugin like Code Snippets to insert the code.

PHP Function to Hide The Product Count

Luckily, WooCommerce offers a lot of handy hooks and filters, so you only need a single line of code in order to disable the categories product count.

[php]
/* ————————————————–
* Hide category product count in product archives *
————————————————- */

add_filter( ‘woocommerce_subcategory_count_html’, ‘__return_false’ );
[/php]

Where to Add the Code

The best place you can add the code would be at the bottom of your child-theme’s functions.php file.

Wrapping Up

Modifying basic WooCommerce features is pretty easy. However, If you are unfamiliar with code editing and resolving potential conflicts, we’d highly recommend to seek help from a qualified WordPress developer.

If you find this snippet helpful and used the custom WooCommerce function on your site, feel free to leave your thoughts in the comments area bellow.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *