WooCommerce PHP Beginner Requires WooCommerce

Hide Product Counts in Category Titles

Remove the "(12)" product count shown next to category names on the shop page.

Tested on WordPress 7.1 PHP 8.3 Updated
functions.php 1 lines
add_filter( 'woocommerce_subcategory_count_html', '__return_empty_string' );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

When the shop page shows product categories, WooCommerce adds the number of products after each name. Small counts can make a store look empty, and many designs look cleaner without them.

How it works

The count is printed through the woocommerce_subcategory_count_html filter. Returning an empty string removes it. The category names and links are unchanged.

Things to watch

  • This affects the category tiles WooCommerce shows on the shop page and in category archives when they’re set to display categories. Category widgets and blocks have their own “Show product counts” option.

How to test it

Set the shop page to show categories (in the Customizer under WooCommerce → Product Catalog) and check that the counts are gone.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only