Skip to content

Instantly share code, notes, and snippets.

@shubhw12
Created June 30, 2020 08:02
Show Gist options
  • Select an option

  • Save shubhw12/d7acc07647bf5924cf60e2472c14b55e to your computer and use it in GitHub Desktop.

Select an option

Save shubhw12/d7acc07647bf5924cf60e2472c14b55e to your computer and use it in GitHub Desktop.
custom count in category box on the shop page. ( https://share.getcloudapp.com/jkuQvNkR )
remove_action( 'woocommerce_shop_loop_subcategory_title', 'woocommerce_template_loop_category_title', 10 );
add_action( 'woocommerce_shop_loop_subcategory_title', 'custom_category_title', 10 );
function custom_category_title( $category ) {
?>;
<h2 class="woocommerce-loop-category__title">
<?php
if ( $category->count > 0 ) {
echo ' <mark class="count">(' . esc_html( $category->count ) . ')</mark>'; // WPCS: XSS ok.
}
?>
</h2>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment