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->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
- Brilliant contest prank - help pick the new CBC hockey theme song - Jul 23rd, 2008
- If You Think Creationism is Bad, Just Wait till You See What's Next - Jun 15th, 2008
- The 6 Most Ridiculous things Banned by Airport Security - May 31st, 2008