How to list out your WordPress tags with a post count for each

26 December 2018

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:

List of WordPress tags

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.

And this can also be adjusted to list categories instead...

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
James Clark
Hi! I'm James Clark and this is my website. Need help with your own website's analytics, SEO, content or ads? Contact me
Copyright © James Clark
0
What do you think? Leave a commentx
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram