ExtreaHead plugin for Wordpress
The ExtraHead plugin makes it easy to insert arbitrary code into the header of any page on a per-page basis. Just create a custom field with the key “extreahead” and the value will be inserted, untouched, into the header.
Sometimes you just want a little custom CSS or javascript on a page.
I was a bit surprised that nothing like this was easily found on the Wordpress codex or via Google, so I took an existing plugin (HeadMeta) and tweaked it to my needs.
The plugin is absurdly simple, in fact it consists of one file:
< ?
function extrahead() {
global $posts;
// only act when viewing a single post or a page. Else, exit.
if ( !(is_single() || is_page() ) ) return;
// Get the post
$post = $posts[0];
// Get the keys and values of the custom fields:
$id = $post->ID;
$data = get_post_meta($id, 'extrahead', false);
if (is_array($data)) {
print "\n";
foreach ($data as $line) {
print "$line\n";
}
print "\n";
}
}
// Hook into the Plugin API
add_action('wp_head', 'extrahead');
?>
[...] ExtraHead, a tiny plugin for Wordpress. I’m sure this functionality exists elsewhere in the Wordpress world, but I couldn’t find it after 10 minutes of Googling so I wrote a plugin. ExtraHead just makes it easy to insert arbitrary code into a page header, on a page-by-page basis. Just add a custom field with the key extrahead and whatever code you want in the header as the value. [...]
Todays projects at Baltimore Squirrels
2 Sep 08 at 4:38 pm