I wanted to add number of posts for menu items that are categories.
For example:
- Category 1 (5)
- Category 2 (8)
- Category 3 (2)
etc…
I edit walker:
get number:
$item_count = $depth == 0 ? get_posts( array(
'post_type' => 'post',
'numberposts' => -1,
'orderby' => 'category',
'order' => 'ASC'
) ) : false;
output:
$item_output .= $item_count ? ' <span>(' . count( $item_count ) . ')</span>' : '';
The result is a postscript to each menu item the number of all posts.
How to modify?
use wp_list_categories
UPDATE for your instance:
with the full code from the link you provided in the comments we add an if statement right before the closing
<a>
FULL CODE:
If you are using some custom post taxonomie you can change the code for this one :
Hope this help someone !!
Regards Mario