Working on this site's HTML sitemap recently, I wanted a way of listing out all my WordPress tags (as links) with a post count for each. Something like this:
This isn't something I was willing to create manually because then I would need to update it every time I published a new post. After a bit of Googling I found a useful snippet of php on the Mobilize Cloud website that took me most of the way there - it listed out all tags as links, but without a post count.
All it took was a slight tweak to echo the count field for the $tag variable (within brackets). The final code is below and you can see it in action on the HTML sitemap.
$tags = get_tags();
foreach ( $tags as $tag ) :
$tag_link = get_tag_link( $tag->term_id );
<a href='<?php echo $tag_link; ?>' title='<?php echo $tag->name; ?>' class='<?php echo $tag->slug ?>'><?php echo $tag->name ?> (<?php echo $tag->count ?>)</a>
And this can also be adjusted to list categories instead...