Recently I shared a snippet of code that will list out your WordPress tags with a post count for each. I should have mentioned that it's easy to adjust this code so that it lists out categories instead of tags. Here's the adjusted snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <ul id="Genre-List"> <?php $categories = get_categories(); foreach ( $categories as $category ) : $category_link = get_category_link( $category->term_id ); ?> <li> <a href='<?php echo $category_link; ?>' title='<?php echo $category->name; ?>' class='<?php echo $category->slug ?>'><?php echo $category->name ?> (<?php echo $category->count ?>)</a> </li> <?php endforeach; ?> </ul> |
That gives you something like the following (a live example!):
How do you do it for a specific category count?
Hi Sir,
Woking fine, thanks.