WordPress – How to Show $get_categories list with Total count of Posts in all Sub Categories?

I have created a simple menu with list of Categories and Count of post inside category 78.

<?php

$args = array(
  'orderby' => 'name',
  'parent' => '78'
  );
$categories = get_categories( $args );
foreach ( $categories as $category ) {
    echo
'<h2>' . $category->name . ' &nbsp; (' . $category->count . ')</h2>';
}
?>

I want to show count of ALL posts including SUB-Category posts, but with this code it only shows the Category count for main Category and SUB-Categories are not included in Count.

Read More

Is it possible to get count of all posts within a category including all post count in sub categories if any?

Related posts

Leave a Reply