WordPressI was very happy to see that the WordPress developers included the ability to “tag” posts. For a long time I’ve been using my own bastardized version of Bunny’s Technorati Tags to add tags to this site. A few days ago I decided to bite the bullet and convert to using the tag system that is now baked into this CMS.

It’s a much more “visitor friendly” implementation of tagging …

Here’s my only problem: The standard WordPress tagging engine is designed so that clicking a tag on a post displays an archives page with all of the other posts tagged with that tag. (Confused yet?) I don’t like that. One reason I don’t like that is because I have not yet managed to transfer all of my tags from the old system to the new, so lots and lots of my posts have no tags. That means if you click a tag for “ovulating kleptomaniac”, for example, you’re not going to get any results. So I have hornswaggled the code a bit to make it so that on this site the tags link to search results for that tag instead. I think it’s a much more “visitor friendly” implementation of tagging.

It’s pretty simple to do it, if you’re interested. In your index.php template (and archive.php, search.php, etc.), within the loop, instead of using the default WordPress tag display function:

<?php the_tags(‘Tags:’, ‘, ‘, ‘<br />’); ?>

I am using the following:

echo "<p class=\"postmetadata\">Tagged with: ";
$posttags = get_the_tags();
if ( $posttags ){
$tagcount = 0;
foreach ( $posttags as $tag ){
if ( $tagcount ) echo ", ";
echo "<a href=\"http://www.davidgagne.net/?s=" . strtolower($tag->name) . "\" rel=\"tag\">" . strtolower($tag->name) . "</a>";
echo "</p>";

You’ll see that I’m using the tag name property instead of the tag slug property. That’s because slug replaces a space with a hyphen and searching my site for los-angeles will not yield nearly as many results as a search for los angeles. I’m formatting everything as lowercase just because I like it better.

So there you go. I hope someone else finds this useful.