If you are content with showing it like this:
Category (x)
Category (y)
Where x and y are the number of posts in the category, then just be sure to include the “show_count” parameter in the wp_list_categories
function:
<?php wp_list_categories('show_count=1'); ?>
As for displaying the posts in a fancier way, paste the following snippet of code where you want to show your categories:
<ul>
foreach (get_categories(array('hide_empty'=>false)) as $category)
{
echo '<li><a href="' . get_bloginfo('wpurl') . '/category/' . $category->category_nicename . '/">' . $category->cat_name . '</a> (' . $category->count . ' posts)</li>';
}
</ul>
This will output:
Category Name (X posts)
You can wrap the (X posts) piece in a <span> tag or other HTML tag if you want to style it separately. In my case, I was looking to position the category name to the left and the number of posts to the right.
Special thanks to John Herren for this one.
vossavant