Skip to content

Instantly share code, notes, and snippets.

@Veesibility
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Veesibility/5af574d04b32a2fbbbfd to your computer and use it in GitHub Desktop.
Save Veesibility/5af574d04b32a2fbbbfd to your computer and use it in GitHub Desktop.
Woocommerce - Add Product Count View in Each Category
/** This code should be added to functions.php of your theme **/
/* Woocommerce - Add Product Count View in Each Category */
add_action( 'woocommerce_before_shop_loop', 'add_product_count_view', 20);
function add_product_count_view() {
$terms = get_the_terms( $post->ID, 'product_cat');
foreach( $terms as $term ) {
if(is_tax('product_cat', $term->name)) {
echo '<span class="count-view">'.$term->count
.__( ' results')
.'</span>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment