Last active
August 29, 2015 14:23
-
-
Save Veesibility/5af574d04b32a2fbbbfd to your computer and use it in GitHub Desktop.
Woocommerce - Add Product Count View in Each Category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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