TangleBones

Ruining Everything for Everyone

TangleBones is the home page of Jemaleddin Cole, a programmer who blogs about technology, politics, autism, and other things he knows very little about. Read more...


PlainTags v0.1

Word­Press 2.3 intro­duces robust tag sup­port to the Word­Press com­mu­nity, and replaces most of the func­tions of long­time favorite Ulti­mate­Tag­War­rior. How­ever, there’s one miss­ing func­tion that I couldn’t live with­out: a plain­text tag output.

By default, WordPress’s the_tags() func­tion out­puts a list of comma-​separated tags that are each links to archive pages of posts with the same tag. This is great for pre­sent­ing tags to users, but not so hot for people that want to do some­thing a little more low-​level. Plain­Tags intro­duces a func­tion called the_plaintags() that works in exactly the same way as the_tags(), but does so with­out wrap­ping each tag in a link. (The reason that this func­tion works so sim­i­larly to the_tags() is that I ripped the code straight from that func­tion and removed the parts that did what I didn’t want. Thank good­ness for open source.)

Why would you want to do such a thing? Well, if you want to use your tags as meta key­words, then this:

<meta name=”keywords” content=”<?php the_plaintags(”,’,',”); ?>”>

…will pro­duce some­thing like this:

<meta name=”keywords” content=”blog,article,foo,bar,baz”>

More impor­tantly for me, you can also replace the func­tions described in this arti­cle to add key­words to your ad blocks based on your tags, thereby ren­der­ing 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 key­words, set a min­inum price for your auc­tions, and give a default key­word in case you have no tags for a post or no ads match your tags.

Hope­fully func­tion­al­ity like this will be added in a future release of Word­Press (by extend­ing the_tags to take another argu­ment to spec­ify plain­text), but in the mean­time please enjoy this plugin:

Down­load PlainTags_0.1.zip

And of course, let me know if you have any problems.

Archives

Categories

© Copyright 2009 - All rights reserved.