Skip to content
ludicrousThe web development desk
WordPress

WordPress Plugin: Head Meta – Add Anything to the <head> of a Post

Latest version: 0.2 – Released 21 March 2007 Ever wanted to add things such as JavaScript or meta data to the <head> of a page when you’re writing a post?

Last reviewed

Description

It usually means editing the header.php file in your blog’s template, which is time-consuming and especially complex if you only want to add it to certain pages or posts. This is where the Head Meta plugin comes in. It allows you to simply type your meta data or your JavaScript into a custom field and have it show up inside the <head> on your post or your page.

Example

On the page for my Firefox Twitter Updater I needed to insert a <link> into the head, but have it only inserted when viewing that blog entry on its own. I typed the whole <link> element into a custom field named “head-meta” and while the plugin is active the <link> shows up in the document’s <head> without having to alter anything in the template. See the screen shot below:

Example of usage of the Head Meta plugin for WordPress

Installation

This plugin is only recommended for people who are comfortable writing HTML by hand and who know what meta data is. If you don’t know why you’d need this plugin, then you don’t need it. For those who do, download the plugin using the link at the bottom of this page, unzip it and drop the head-meta folder straight into your wp-content/plugins directory and activate the plugin from WordPress’ Plugin panel.

Your WordPress theme must have the wp_head() function inside the head for this plugin to work. The default themes bundled with WordPress have this, and many themes you can download do too, but if this plugin doesn’t work for you please ensure this function is in the head of your theme.

Usage

Using this plugin is easy. Simply type the meta data which is to go into the <head> of your post or page into a new custom field and name the key “head-meta” (without the quotes). Take another look at the screen shot above if you’re not entirely sure.

Download

ZIP file from lud.icro.us

More Details

The meta data will only show up in the <head> of your document when viewing the post or page on its own (ie. at the post’s permalink). It will not show up, for example, on the front page of your blog even when the post concerned is visible on the front page. This is because my particular needs were that I only wanted the meta data to show up when viewing the post on its own.

Any comments, questions, queries, suggestions, complaints, etc, please leave a comment below!

From the original thread

45 replies

45 replies were left on this page between 2007 and 2009, kept as they were written. The avatars, profile links and reply form of the software that collected them are not part of this archive, and the addresses readers pasted are kept as text rather than as links.

  1. Storm

    Ok, now I’m confused. There is already a well known plugin by Dougal Campbell named “HeadMeta” which I believe currently is at version 1.3.

    I think the similarities in names is more than a little confusing. It seems like yours is a bit different in that it allows the input of JavaScript and not just meta keyword tags, but it is still confusingly close.

  2. Hackemster

    It gave me nothing but blank screens everywhere until I deleted the php file.

  3. Ludicrous

    Storm, I hadn’t come across the previous plugin named HeadMeta. You’re right, the names are very similar, I may change mine as obviously my plugin came after!

    Hackemster, what version of WordPress are you running? Did this happen before or after you tried inputting some data in the custom fields? What other plugins are you running?

  4. Danny

    Nice plugin!
    Feature request – tweak it so it can insert @profile URIs to the head element itself, for use with microformats and/or GRDDL (multiple URIs can go in, space-separated).

    See:
    http://microformats.org/wiki/profile-uris
    http://www.w3.org/TR/grddl-primer/

  5. datacode

    It fails for me also… Blank screen when activating in 2.0.4 and 2.1 (fresh install)

  6. Ludicrous

    I’ve updated the plugin to address the issues of a blank screen appearing on some setups. Hopefully this fixes those problems. Download version 0.2 here.

  7. datacode

    John – It now works for me! Thanks for the quick fix.

  8. Boris

    Awesome !
    Like you, I had to use custom JS and CSS on several posts.

    I’ve installed this, it works great. Thanks !

  9. Shaun

    I have installed this plugin and it seems to be exactly what i want for adding keywords and descriptions to the head of my posts. The only problem i have is it only seems to let me put one set of meta information in for each post, for example i created meta description information for one of my posts and that worked perfectly, i then went to add the meta keywords but they don’t show up in the code for some reason?

    Tried it on a few different posts with the same results.

    Any ideas why this might be happening ?

    Thank You

  10. Ludicrous

    Shaun, thanks for trying the plugin. That’s a side effect of the fact that I knocked up the plugin in 10 minutes :-)

    If you want to add more than one meta tag you’ll just have to add them all into the same custom field (“head-meta”) one after the other. See the image below:

    2metas

  11. Shaun

    Hi John,

    Thanks for the reply, i figured it out by playing around with it. Working great now. Thanks

    Shaun

  12. oggin

    works nice, 10x for plugin

  13. Izzyweb

    Good this is script fo WP
    Thank you

  14. MichaelM

    Thanks, this plugin worked perfectly for me! Great work. =]

  15. Rene Kriest/ProBloggerWorld.de

    This plugin seems to be huge, thank you!

    This was exactly what I was looking for, injecting some individual meta-tags for special website adjustment.

    Almost every SEO-Plugin lacks editing meta-tags beside keyword- and description-tag. I highly doubt that those coders now the real deal about SEO. ;)

    I will give it a try and if it works out – what I really expect :) – I gonna write a review and recommand it to my dear blog-readers here in good ol’ Germany.

    Have a nice weekend.

    Regards,

    René/ProbloggerWorld.de

  16. Ludicrous

    Rene, thanks for your comment. Glad you find the plugin useful!

  17. manele

    thank you for this useful plugin! you helped me a lot on my blog!

  18. Paul

    Great plugin. I installed it and got it working in a matter of minutes.

    One question: I installed this plugin in order to edit and control the keywords and descriptions for each page/post. In order to do that, I removed the keywords and description lines from the header.php code. But I realized that now my homepage doesn’t have these lines.

    I guess my question is: can there be, for instance, 2 keywords lines, one general that appears on the homepage and all post pages, and one with more specific keywords that is just on individual pages? Or is there some problem with doing that?

    Thanks.

  19. Ludicrous

    Hey paul, for complete control over meta tags you’d be better off with a plugin which is designed specifically for meta tag control, for example “Another WordPress Meta Plugin“. Cheers, John.

  20. Paul

    hey John. thanks for responding. i guess i thought that that’s what this plugin was for. but if the one you suggest offers more control, i’ll try it and see how it works. thanks. – PAUL

  21. dyingtoknow

    hi John, I’m a little bit confuse over what’s this plugin doing, I was searching for plugin that could insert meta desc /keyword into homepage/archieve pages/ search result, etc. Because the old plugin that I use, can only display meta desc/keyword in the single post pages. This makes my homepage doesn’t have meta desc (SE grab it from the text in my sidebar which is not related to the content), not just the homepage, the archive pages that is indexed by SE also give weird meta desc.

    Can your plugin help me solve this issue John ?

    Thanks

  22. Ludicrous

    dyingtoknow, this plugin will only insert information into the head of a sinlge post or page, not the home page. Take a look at the list of other meta plugins on the WordPress Codex.

  23. Trever Fischer

    Nicely done. Saved me a few minutes of making the plugin myself :)

  24. Cockefeller

    I’m a complete amateur when it comes to PHP and CSS, so this might be a stupid question, but here goes.

    On my site discordian.ca, I installed the plugin (which is great, btw) for the purpose of simply changing the colour of my links (when they are hovered over) on individual posts and pages. To change the links to the colours I desired, I added this to the of a post using the head-meta plugin:

    a:hover {
    color: #ff7800;
    text-decoration: none;

    Everything seems to be working fine on IE and Firefox, but not on Safari, which still displays the links with the regular colour from the main style.css file.

    Here’s the page: http://discordian.ca/poly-see-dept/down-the-memory-hole/

    Thanks in advance. Hail Eris!

  25. Cockefeller

    Nevermind. I fixed my problem… Why does it always take me seeing my faulty code posted in the comments of some site before I realize I’m missing a stupid } ?

    Sorry to pollute your comments with this crap…

  26. Ludicrous

    No worries Cockafeller, glad you got it fixed.

  27. Dana Lookadoo

    Is your Head Meta Plugin still available? The download link above returns a 404 page.

  28. Ludicrous

    Dana: Yes it is still available, give me a few minutes and I’ll fix the link!

  29. Ludicrous

    All fixed.

  30. Dana Lookadoo

    Thank you, John! I’m excited to give this a try. I’m using the Shifter Theme.

  31. Dana Lookadoo

    John, I’ve loaded it successfully. I’m looking for a way to add JavaScript to the head of every page on the site. Does this plugin have any “global” options to do this? It appears to be designed for a page-by-page basis.

  32. Ludicrous

    Dana: This plugin is just for single posts and pages. Adding something to the head of every page is simple but it doesn’t look like there is a plugin out there to do it.

    Try this:

    <?php
    /*
    Plugin Name: Head Stuff
    Description: Head stuff
    Version: 1.0
    Author: Ludicrous
    */
    function jb_head_stuff() {
    ?>

    <?php
    }
    add_action( 'wp_head', 'jb_head_stuff' );
    ?>

    You’ll have to add your JavaScript in manually where it says “Put all your JavaScript here!”.

  33. Dana Lookadoo

    I don’t have access to the file with this theme. I will inform the developer. He’s open to writing a plugin. I’ll share with you the outcome. THANKS!!

  34. Dejan Cancarevic

    very good plugin, thanks a lot!

  35. Jakki

    Hey just wanted to thank you for this awesome plugin. It was EXACTLY what i was looking for :D

  36. David Roberts

    Great plugin – thankyou :)

    Dana: You could try the Header-Footer plugin available from http://wordpress.org/extend/plugins/header-footer/

  37. Dana Lookadoo

    Thanks, David for the plugin note. I’m bookmarking this for future reference. I’m using the Shifter theme that is a little tricky. The developers took John’s code and revised it to work for Shifter! I’m bookmarking the Header-Footer plugin and can see why it’s rated with 5 stars!

    Thanks also to Ludicrous for great contributions!

  38. Jon Robinson

    Thanks for the plugin.

  39. Umut Benzer

    Thank you. That was what i was looking for. :)

  40. Rob Thunder

    Thanks John for taking the time to create this but when I installed it and tried it out (tried inserting some Javascript) I noticed that all the double quotes in the code get escaped (i.e., a backslash is inserted before all double quotes) essentially rendering the code useless. I had to use a ‘plain text’ hack that I worked up a while ago to get WordPress to stop escaping double quotes when using your plugin. Is there something I’m missing? Because nobody else has mentioned this.

  41. Ludicrous

    That’s odd Rob, there’s no reason why the double quotes should be getting escaped as the plugin only uses WordPress’ built-in functions for displaying the content on the page.

    I can’t reproduce the problem. What version of WordPress are you using?

  42. Rob Thunder

    I tested it on two different sites (and themes) using WordPress 2.6.1. I also tested in both Firefox 3 and Internet Explorer 7 to see if it was a browser specific problem. Same results. All double quotes get escaped. I also tried disabling any plugins which I thought might be creating a conflict and still the same. I’m still going to use your plugin as it’s very useful but I’m still wondering how everybody else manages to use it without having to apply a hack to get WordPress to stop escaping double quotes.

  43. Ramiro Ruiz

    How can i show the full post in the main page without click in the permanlink?

    i want to show a full post in the index, just one and the most recent without click in the title, i want to use this plugin to put some JavaScript in one post, but i want to show up without clicking in the title so i don’t know if is possible to see
    “www.myblog.com/2009/01/05/sample-post/” JavaScript in “www.myblog.com”

    sorry for my english =S

  44. Web Hosting

    Thanks for this mod. its working fine for our wp_head

    Thanks once again.

  45. Tim

    Thanks for this plug in in. Needed to be able to set a cookie just on my contact form page and this was exactly what I needed.

More from WordPress

All of WordPress