Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function.php:
- function wp_get_cat_postcount($id) {
- $cat = get_category($id);
- $count = (int) $cat->count;
- $taxonomy = 'category';
- $args = array(
- 'child_of' => $id,
- );
- $tax_terms = get_terms($taxonomy,$args);
- foreach ($tax_terms as $tax_term) {
- $count +=$tax_term->count;
- }
- return $count;
- }
- show:
- The total number of posts under "My Awesome Category" is <?php echo wp_get_cat_postcount(2); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement