Wordpress Help - Displaying a good Tag Cloud

By default, if you use the Tag Cloud Widget, chances are that it won’t give you a good looking Tag Cloud. After I migrated to the widget world, my tag cloud looked like this:

TagCloudBad Is that ugly or what? But that’s what you would get once you have a lot of posts with a lot of tags.

In addition to this, the tag cloud widget doesn’t let you configure anything. I like to be able to specify a size which my tags should take. And, I also don’t like to display all the tags (only top so many).

While the WordPress API allows you to fetch a list of tags based on your own parameters, there is nothing out of the box which will allow you to display them in a widget in a side bar.

Here’s what I did. I downloaded the Executable PHP Widget by Otto. This widget allows you to execute PHP code (duh!), which is something that the text widget doesn’t do. Once I installed this plugin and activated it, in the presentation admin area of WordPress, I was able to add a PHP widget. Now, once you do this, half the battle is done. Inside it, I put a simple line of PHP code. This is what it looks like:

<div align=center>
<?php wp_tag_cloud(’smallest=5&largest=13&number=25&exclude=4,5,47′); ?>
</div>

This little line of code does the following:

  • Fetches the top 25 tags from my tag list.
  • Varies their sizes from 5 to 13 based on popularity.
  • Excludes tags with IDs: 4,5,47
  • And the <div align=center></div> puts the resulting list in a centered alignment.

The result looks like this:

TagCloudGoodHopefully, someone else is facing this problem as well, and this post helped. :)

Of course, if you want to tweak your tags more, you can go and study the WordPress API for more options.



You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Wordpress Help - Displaying a good Tag Cloud”

  1. [...] like the use of a tag cloud to explain what certain content is all about. I even try to have a good looking tag cloud on this blog. However, my tag cloud never looked as good as the ones I am about to show you [...]

Leave a Reply