Created
June 30, 2020 08:02
-
-
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 )
This file contains hidden or 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
| 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