Put Related Tags in Category Pages with Ultimate Tag Warrior

Blogs are an integral part of whole “web 2.0″ business, so it’s not too surprising that bloggers like adding tags to their posts. If you are using WordPress, one of the best ways to add tagging functionality to your site is with a plugin called the Ultimate Tag Warrior.

This article won’t go into all the great features included with Ultimate Tag Warrior (UTW). If you are new to the plugin, I suggest reading this great article by Lorelle. You can use it to show related posts, tags related to a particular post, and a bunch of other stuff. But there’s no easy way to show tags related to a particular tag or category.

If you take a look at one of our category page, for example the Environment category page, you notice a list of related tags. Here’s how I did it.

Let’s assume you’ve already got UTW installed, activated, and you are including categories as tags. Go to your theme and open up your archive.php file. The first thing you need to do is get your category name into a php variable:

$category_name = single_cat_title('', false);

Next we need to get it into the structure that UTW uses internally for tags. Feel free to dig around in ultimate-tag-warrior-core.php to learn all about it, but you can trust me that the following line will work:

$tags[0]->tag = $category_name;

Now we need to tell UTW what format to use to display the tags, using the correct structure for UTW formats:

$format = $utw->GetFormat('coloredsizedtagcloud', '');

Finally, we give UTW the tag and the format and call ShowRelatedTags. That last parameter is the number of tags to retrieve.

$utw->ShowRelatedTags($tags, $format, 30);

Why do all this? Tags make your content easier to browse and are a nice little SEO boost. The Category page seems like a logical place to put tags, so I thought it would be worth a try.

Hopefully this has been helpful. It took me a couple of hours of digging around to figure it out, so I thought I would share.

Let me know what you think below – if I get enough response, I’ll code this up into a WordPress plug-in to make it easy to install.

Written by Jason

Last 3 posts by Jason

  1. Is it possible for wordpress.com? I’ve been looking around for the codes.

    October 8th, 2007 at 12:35 am
  2. Sorry, I’ve never used wordpress.com, I’m not sure I can help you there.

    October 11th, 2007 at 7:18 pm
  3. [...] Ultimate Tag Warrior is a great WordPress plugin that lets you add tagging to your blog and build your own folksonomy. You can use it to show related posts or a nifty tag cloud. [...]

    A Dirty Hack to Fix the Disappearing Tags Problem in Ultimate Tag Warrior - Unsought Input
    October 30th, 2007 at 12:05 am

Post a Comment

(or leave a trackback to your blog)