Add Link to the Count in WooCommerce Product Category Menu

The WooCommerce product category menu can be manipulated by making a copy of the walker class it is defined in and editing it.

The WC_Product_Cat_List_walker class lives in wooc0mmerce/includes/walkers/class-product-cat-list-walker.php, you can make a copy of this and include it in your child theme and include it. Best to create a classes subfolder in your child theme and add the file there – then include it in via your functions.php file like so…

require_once( get_stylesheet_directory() . '/classes/class-product-cat-list-walker.php');

In this gist below the only difference from the original is adding a link to the count value of the products that belong to the particular term/product category, from line 105 – the link will go to the relevant archive page for that product category.

Leave a Comment