In which I explain how to improve a plugin

Three Simple Steps to Fix Technorati Tags

According to the tag help page at Technorati, all you have to do to have their system “find” your tags is (1) add a rel=”tag” parameter to your links and (2) make sure those links end with the word you are tagging (e.g. something.com/tag). The first part is simple. The second part is easy, but not very practical. More importantly, though, is the fact that neither of these seem to actually work. As far as I can tell Technorati does not read your entire post and strip any tags it finds. In fact it seems that Technorati only reads your RSS and analyzes that to determine how to tag your posts. That’s okay, though, because I can tell you how to convert your WordPress tags into rss category nodes so that Technorati indexes them.


I’m using Bunny’s Technorati Tags plugin on this site. (If you’re interested, you can view a list of all the plugins I use to make davidgagne.net work.) Bunny’s plugin is, in my humble opinion, the easiest of all the WordPress tag plugins. It stores your tags in the wp_postmeta table and is easy to configure.

Here are the modifications I made to Bunny’s excellent plugin — and my WordPress RSS generator — to improve Technorati’s ability to index my tags:

1Update an Existing Function

Open your bunny-tags.php file and create a new parameter for the get_bunny_tags_list() function.
Change

get_bunny_tags_list($before, $after, $separator)

to

get_bunny_tags_list($before, $after, $separator, $simple = 0)

(Adding $simple = 0 as a parameter tells the code that we want this function to accept an additional piece of data, but if it’s not there to just assume it’s zero.)

Now we’ll use our new parameter to tell the function to use an alternate function for displaying tags. Change:

$technorati_tags_list=output_bunny_tags($technorati_tags, $before, $after, $separator);

to

if ($simple == 1){
$technorati_tags_list=output_bunny_tags_simple($technorati_tags, $before, $after, $separator);
}
else{
$technorati_tags_list=output_bunny_tags($technorati_tags, $before, $after, $separator);
}

2Create a New Function

Create the output_bunny_tags_simple function. This is the same as the output_bunny_tags function except it doesn’t include the links; it simply prints the tags.

function output_bunny_tags_simple($tags_array, $before, $after, $separator){	
	if(!empty($tags_array)){
		$tags_list = $before;
		foreach($tags_array as $tag){
			$display_tag = urldecode($tag);
			$tag_link = $display_tag . $separator;
			$tags_list .= $tag_link;
		}
		$chomp = 0 - strlen($separator);
		$tags_list = substr($tags_list, 0, $chomp);
		$tags_list.=$after;
	}
	return($tags_list);
}

Great! That’s all you have to do to get Bunny’s plugin to publish unformatted tags. Now you can use those in your RSS feed so that Technorati finds them and associates them with your post.
Here’s how to do that:

3Update Your Feed

Open your wp-rss2.php file and find the line

<?php  the_category_rss() ?>

Just below that add the following code:

<? echo strtolower(get_bunny_tags_list("<category>", "</category>", "</category><category>", 1)); ?>

Now your feed will include your tags as if they were categories. Technorati will then add them to your posts properly.

Post the first comment:

I'll never share your email address and it won't be published.

What Is This?

davidgagne.net is the personal weblog of me, David Vincent Gagne. I've been publishing here since 1999, which makes this one of the oldest continuously-updated websites on the Internet.

bartender.live

A few years ago I was trying to determine what cocktails I could make with the alcohol I had at home. I searched the App Store but couldn't find an app that would let me do that, so I built one.

Hemingway

You can read dozens of essays and articles and find hundreds of links to other sites with stories and information about Ernest Hemingway in The Hemingway Collection.