PlainTags v0.1
WordPress 2.3 introduces robust tag support to the WordPress community, and replaces most of the functions of longtime favorite UltimateTagWarrior. However, there’s one missing function that I couldn’t live without: a plaintext tag output.
By default, WordPress’s the_tags() function outputs a list of comma-separated tags that are each links to archive pages of posts with the same tag. This is great for presenting tags to users, but not so hot for people that want to do something a little more low-level. PlainTags introduces a function called the_plaintags() that works in exactly the same way as the_tags(), but does so without wrapping each tag in a link. (The reason that this function works so similarly to the_tags() is that I ripped the code straight from that function and removed the parts that did what I didn’t want. Thank goodness for open source.)
Why would you want to do such a thing? Well, if you want to use your tags as meta keywords, then this:
<meta name=”keywords” content=”<?php the_plaintags(”,’,',”); ?>”>
…will produce something like this:
<meta name=”keywords” content=”blog,article,foo,bar,baz”>
More importantly for me, you can also replace the functions described in this article to add keywords to your ad blocks based on your tags, thereby rendering non-contextual ads contextual:
auctionads_ad_kw = “<?php the_plaintags(”,’ minprice:20,’,’ minprice:20,’); ?>minprice:20 ipod -case”;
The above will add your tags to your keywords, set a mininum price for your auctions, and give a default keyword in case you have no tags for a post or no ads match your tags.
Hopefully functionality like this will be added in a future release of WordPress (by extending the_tags to take another argument to specify plaintext), but in the meantime please enjoy this plugin:
And of course, let me know if you have any problems.
Popularity: 5% [?]

Comments