Remove Product Count from Categories on WooCommerce

If you are familiar with WooCommerce plugin, then you should have known by now that by default Product categories or subcategories displays the product count. This may or may not be a good feature depending on the site owner’s taste or preferences. However, on one of my recent project the site owner wanted me to remove the product count.

Removing the Product Count

Product count can easily be removed from your theme by using the following snippet.

<?php
function remove_products_count() {
   return;}
add_filter('woocommerce_subcategory_count_html','remove_products_count');
?>

All you need to do is to copy this snippet and paste in on your theme’s functions.php page. Update the page and you are good to go.

Get Creative

Just in case if you want to get creative and to do little extra with the snippet mentioned above, you can do that as well. Here is an example of such idea that I already implemented on one of my client’s site. You can tweak this snippet as well and get creative with your ideas.

Remove Product Category CountRemoving Category Product Count in WooCommerce.

All I did here is simply returned a different variable instead of product count to fill up the extra space. Please remember that this text will show up within the product category or subcategory title (within <h3></h3> tag). So, it would be wise to wrap up your custom content with an element for better customization (with CSS) options.

<?php
function return_shop_now_text() {
   $shopnow = '<span class="shop-now">Shop Now &rarr;</span>';
   return $shopnow;}
   add_filter('woocommerce_subcategory_count_html','return_shop_now_text');
?>

Simply copy and paste this snippet on your current theme’s functions.php page just like before and you are ready to roll. Feel free to drop a line if you have any question on this regard.

Today In History

  •  
  •  

Comment

2 Comments

  1. GeorgePublished: 4 years ago

    Thank you!! Finally a snippet that was actually compatible with my theme. Thank you.

    • IftekharPublished: 4 years ago

      I am glad that it was helpful for you 🙂

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.