Tags to Meta Tag Keywords in WordPress

I’m prepping my blogs for a WordPress 2.0 upgrade and was looking to see how best to add tags to the system. I decided on the Ultimate Tag Warrior plugin (you gotta love these plugin names – like an IT department would have come up with that – or the term webmaster…). I then figured out how to get the tags to pop out as keywords in a single post’s meta tags.
The Tag Warrior plugin allows you define different formats for the tags. You can display as a list, as links to Technorati or other configurations. I made a configuration for meta tag keywords. Just go to the ultimate-tag-warrior-core.php file and scroll to where all the $predefinedFormats are happening (around line 1142 in the version of the plugin I’m using).
Then pop in this code:
$predefinedFormats["metatagkeywords"] = array (
"pre"=>"<meta name=\"keywords\" content=\"", "default"=>"%tag%, ", "first"=>"%tag%, ", "last"=>"%tag%", "post"=>"\">", "none"=>"");

Save that and then go your template’s header.php file. Add in this bit:
<?php if ( is_single() ) { ?>
<?php UTW_ShowTagsForCurrentPost("metatagkeywords") ?>
<?php } ?>

That will pop the keywords only for a page displaying a single post.

2 thoughts on “Tags to Meta Tag Keywords in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *