My first WordPress plugin: HeadMeta

Stumble It!

Mark Pilgrim was in the #wordpress IRC channel earlier, asking if there was some way to add <link> and <meta> tags to the <head> section of a page for specific posts. It seems he wants to control how various search engines and other bots index individual posts. I replied that he could do this using the custom fields feature.

A short while later, I had written my first plugin for WordPress: HeadMeta: .ZIP, .tar.gz, .phps, .txt.

To use this plugin, you add key/value pairs in the Advanced Editing interface. In particular, you’ll want to add keys named “head_link” and “head_meta”. The value will be plugged into the generated <link> or <meta> tag. For example, if you added the following keys and values:

Key Value
head_link rel=”seealso” href=”http://example.com/movies/”
head_meta name=”keywords” content=”entertainment,movies”

This would generate two tags in the <head> of the page, when someone visited the permalink for the post:


<link rel="seealso" href="http://example.com/movies/" />
<meta name="keywords" content="entertainment,movies" />

This will be useful for any situation where you want special <link> or <meta> tags generated for specific posts.

UPDATE 2005/07/14: I’ve updated the plugin to version 1.1, which adds a new feature: if you have a key named “keyword” or “keywords”, it will automatically generate a standard “keywords” meta tag. For example, if you have the following custom field:

Key Value
keyword pets, dogs, canines, training

The result would be:


<meta name='keywords' content='pets, dogs, canines, training' />

UPDATE 2005/10/15: I updated with a bugfix. The new version is 1.2.

UPDATE 2007/02/05: Version 1.3 is the newest version, which is now WordPress 2.1 compatible (it should still work with older versions, as well). Thanks to Gerald for pointing out the problem!

Stumble It!

I'm happy to use Increase Sociability.