Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add Shortcode to show posts count inside a category
- function category_post_count( $atts ) {
- $atts = shortcode_atts( array(
- 'category' => null
- ), $atts );
- // get the category by slug.
- $term = get_term_by( 'slug', $atts['category'], 'category');
- return ( isset( $term->count ) ) ? $term->count : 0;
- }
- add_shortcode( 'category_post_count', 'category_post_count' );
Add Comment
Please, Sign In to add comment