WP plugin: Head META Description
- plugin:
- Head META Description
- version:
- R1.1.2
- download:
- head-meta-desc.zip
- source:
- head-meta-desc.php
Lazy WordPress plugin posting time! Another of my did it but for some reason didn’t release it plugins, Head Meta Description provides an automatic meta description tag for your blog, inserting a dynamic description depending on the query-type (i.e. page you’re on). Some search engines are supposed to love this tag, so I guess we should, too.
Ooh ooh, get ready for brain-numbing install instructions:: download the zip file and extract head-meta-desc.php from it, upload this to your wp-content/plugins/ directory, and activate Head META Description under Plugins in WordPress. Phew! If your theme already calls the wp_head() plugin hook from the <head> element, the plugin will work right off. If not, add this on its own line (before the closing </head> tag) in the header of your theme, typically in the header.php template:
<?php wp_head(); ?>
The plugin outputs a brief summary of a post’s or Page’s excerpt (the first # words of it, # defined in the $post_desc_length user-configurable variable described below), a category’s description when on category pages, and the blog’s tagline when on any other page or query-type. You can also set your own default description (through the $default_blog_desc variable), as well as override post and Page descriptions with a custom field (the $custom_desc_key variable defines the key; your custom field value would be the description for that post or Page).
Head META Description provides four user-configurable variables. These are:
- $default_blog_desc
- Setting this overrides the use of the tagline (Options > General in WordPress) for the default description on your blog. If you don’t use the tagline, edit this line. Default value is
''(empty). - $post_desc_length
- Length of the description in words for post and Page descriptions (the first # words of the excerpt, or post content). Default value is
20. - $post_use_excerpt
- This tells the plugin to use the excerpt for description on posts, if one exists. Set this to
0(zero) to force post content as description. Default is1. - $custom_desc_key
- Name of the custom field key used to override post or Page excerpts for descriptions. Default is
description.
You can change these variables by editing the plugin file online through the plugin editor (Plugins > Plugin Editor, then select the plugin file), or offline in a text editor.
Yes, there are a few other plugins similar to this one (a problem I keep stumbling over), but I believe this one is a bit more complete in options and variety of descriptions it displays. So there. If you happen to be using the 0.4 version of Head META Description, there is no functional difference between that one and this (R1). I just prettied things up for release.
Author: Kaf Oseo
Categories: WordPress
Comments: (171) · Leave a comment · Comments RSS2 · Trackback URL
great plugin
tnx :)
hi,
I read about tweakin head meta desc so that you can put a custom description for your main page.
——-
The tweak says that if the string-length of the description tag = 0, then it reverts to a separate description tag. Thus on your index.php page or any other page where there’s no specific excerpt to use, it’ll revert to your default description. The tweak is as follows:
if ( strlen( trim( $description )) == 0 ) {
$description = ‘Hotdogs rock my world… Yum’;
}
—————
I tried to modify the head meta desc plugin, but am getting a parsing error on line 65 . See code below .
Can you please let me know how correct the error or if you can email me the modified plugin
thanks
————————————————————
Hi !
I took the liberty of modifying your (nice) plugin to make it also generate the meta keywords element.
I hope that you won’t mind…
Cheers,
David (http://www.davidsoft.org)
function head_meta_desc() {
/* >> user-configurable variables */
$default_blog_desc = ''; // default description (setting overrides blog tagline)
$post_desc_length = 20; // description length in # words for post/Page
$post_use_excerpt = 1; // 0 (zero) to force content as description for post/Page
$custom_desc_key = 'description'; // custom field key; if used, overrides excerpt/content
$custom_tags_key = 'tags'; // custom field key; if used, overrides excerpt/content
/* post;
$post_custom = get_post_custom($post->ID);
$custom_desc_value = $post_custom["$custom_desc_key"][0];
$custom_tags_value = $post_custom["$custom_tags_key"][0];
if($custom_desc_value) {
$text = $custom_desc_value;
} elseif($post_use_excerpt && !empty($post->post_excerpt)) {
$text = $post->post_excerpt;
} else {
$text = $post->post_content;
}
$text = str_replace(array(”\r\n”, “\r”, “\n”, ” “), ” “, $text);
$text = str_replace(array(”\”"), “”, $text);
$text = trim(strip_tags($text));
$text = explode(’ ‘, $text);
if(count($text) > $post_desc_length) {
$l = $post_desc_length;
$ellipsis = ‘…’;
} else {
$l = count($text);
$ellipsis = ”;
}
$description = ”;
for ($i=0; $icat_ID) {
$description = trim(strip_tags($category->category_description));
}
}
}
if($description) {
} else {
$description = (empty($default_blog_desc)) ? trim(strip_tags(get_bloginfo(’description’))) : $default_blog_desc;
}
echo “\n”;
if($custom_tags_value) {
} else {
$custom_tags_value = ‘david book books software review reviews article articles griddler pocket pocketgriddler pocketpc freeware puzzle game’;
}
echo “\n”;
}
I found this plugin very useful. The Meta Description text is displayed by Google on the search results for my site — and this plugin let the various posts (and pages!) display their own text — rather than the same text for every page, which is the Wordpress default. Thanks very much.
Doesn’t seem to be working with Wordpress 2.0 is there an update? Seems to have problem on category pages. Thanks!
Miles, I tracked the problem to 2.0 dropping $cache_categories as a global (outside the WP_Query class, at least). R1.1 of the plugin works around this, and should play nice in WP 2.0.
I just installed R1.1. It’s still giving me trouble with WP 2.0 category pages. Too bad, I love this plugin.
Amy, I need more information than that to troubleshoot what the problem is for category queries. Can you provide details on what you are (or are not) seeing?
With R1.1 and Wordpress 2.0, I get the following error on Category pages:
Warning: end(): Passed variable is not an array or object in /my_directory_info/wp-content/plugins/head-meta-desc.php on line 60Do you need a list of my currently active plugins?
Please email me if you need additional information.
Thanks!
I get the same error as Amy, but only in categories with no posts. The categories that have posts work fine for me.
Thanks Amy and Miles. Both your comments helped me track down the issue. Download R1.1.1 and see if this clears the error (and displays the description, naturally) in categories.
Cleared the error on my category pages but now there is no meta description. Here’s one of my category pages… http://www.marketingwithmiles.com/category/general-internet-marketing/
Ok Miles, once more. I went a different way in capturing category description, which *should* work considering it’s pulled from a WordPress (rather than a PHP) object. But (!) if it fails, I’ll have to go with a dreaded sql query to retrieve it. Nooo!
That cleared up the errors. Meta descriptions are showing up on post pages, but not on the category pages.
Is there a way you could integrate the keyword code that David posted above into Head Meta Description? I can’t figure out how/where to insert it to get it to work. I really like your meta description!
Awesome plugin! I haven’t got it installed yet, but I’ve got a feeling that it will work very nicely.
Very Very Nice. Just installed it and… that was it. Works right off the bat!
Hey there, haven’t heard from you in a while. Emailed you to let you know that there is still no category desc.
Also left a donation hopefully you go it.
OK, I found something, if you do not use a custom description for a category, the plugin provides no meta description. In categories where I do have a custom description it does provide the meta.
I gave up on using metatags a long time ago–if this works I’ll be happy :)
A very useful plugin. Thanks for that. I have a question though, some posts before me David posted some additional code to have the plugin also add metatag fields.
I have tried to fiddle a bit with the code and merge it with the original plugin code but my skills are pretty much sub-zero. I was not bale to get it to work.
Is there any chance you will add this new code to the original?
Is there anyone reading these commments who has been able to succesfully merge the plugin with the code from David and is willing to share with us his solution/code/modified plugin?
Thanks,
G.
Nice Plugin! This is one of the best plugins I have :)
To bad I cant make it work with keywords also I must be doing something wrong.
Pls drop a line in my blog if you feel like it. / Marcus
Ps I had great results so far in seo contests partly because of this plugin.
Excellent!! Thanks! Did you post this on Wordpress’ plugins list?
Thanks very much for the plug-in.
Searched the documentation and looked at numerous other plug-ins and decided to go for this one.
Questions: I am using it “as-is”
Any recommendations if one should change the default values ie increase word length
Herman, the plugin’s
$post_desc_lengthvariable is what you’re looking for. It’s set to20(words) by default.You have to edit the plugin file to change the variable’s value—either through the plugin editor in WordPress or a text editor offline. Look for the user-configurable variables section marked off at the top of the plugin’s head_meta_desc() function. That’s where you’ll find it.
I installed the plugin but nothing seems to happen. I read the instructions clearly but perhaps iam missing something.
This is what i have now
[lots of header code...edited]
Matt, I checked your site and I’m seeing meta tags for description on individual posts, Pages and categories. Just nothing on the home page. Do you have a description (i.e. “tagline”) filled out under Options > General, or given the $default_blog_desc user-configurable variable in the plugin a value?
By the way, I’m constantly amazed at what you’ve pulled off with WordPress over there. Great site.
Thank you for your answer and your kind words Kaf!
I filled out the tagline under options / general a few months ago but i never included it in the pages. I just use the meta description tag on it’s own in the header.php The result is that every page / post / category has the same description. If it is possible i want a different discription for everything. Just like the titletag.
Do you have any idea what i should do?
Thanks a lot for your time and help.
I installed this plug-in on my blog and I love it, except I discovered that I naturally don’t mention very many keywords in the first paragraph of my post, so for optimum SEO you’ll still have to add a custom meta description to each page.
help!
when I look for categories on my blog I’ve got a error mess
Warning: Invalid argument supplied for foreach() in /todolosolido.com.ar/weblog/wp-content/plugins/head-meta-desc.php on line 56
and I don’t repeart it
for example, look at http://todolosolido.com.ar/weblog/categorias/libros/
thanks
I’m sorry, at the new version (1.2) it’s fixed. forget my previous comment :-)
Thank you!
I am add
echo “#meta name=\”keywords\” content=\”$description\” /#\n”;
in line 73 for meta “keywords”
Hey,
Awesome plug-in! Thanks a ton!
Just one little bug though…
All of my pages show up as having empty description tags. Instead of the default…
I guess because there is no excerpt for pages in Wordpress 1.5. That and all my pages do not have text written out by me. All my pages are created via plug-ins.
So anyways if you could please fix this so there is never an empty description tag, so in the cases there would be simply display the default tag as specified in WP’s admin cp.
Thanks a lot,
Will
Hi,
Thanks for all your hard work, the plugin it works great.
One problem I’m having though…
How do I get a description to show in a category listing?
Thanks in advance!
Kaf,
I’d like to suggest a feature: customizing of the title tag in addition to the meta description tag. It would be a big SEO benefit to vary the title tag from the post/page title. For example, you might want to set this post’s title tag to “Head META Description Tag Plugin: guff WordPress Plugins” by defining that as a custom field. That would boost this page’s rankings for “meta tag wordpress plugin” as well as a bunch of other search terms.
What do you think?
Stephan
That’s some sweet ass plugins!
Hi Kaf,
Just installed the plugin with my wordpress 2.0 blog. Works like a charm.
Thanks
agree, super kick ass!
i’ve always think wordpress is sooo suck because there’s no easy way to customize the meta datas. but ur plugin change my mind totally…surely will be using WP more often now. thx!
Dude,
I was reading up on the plugin and the dozens of comments. At the beginning I found it quite complicated. As I have zero technical knowledge. But once I uploaded it. I realised I had nothing to do. It auto populates the title and the description, WHICH IS AWESOME!
However, I have two very simple query. If you could help me with them it would be great.
1) My page source does not show any keywords? why is that?
2)Can I add my category name to the title along with my website name???? and then the description follows?
Note: I just installed “Jerome’s Keywords Manager” & “Jerome’s Keywords Plugin”. Which to my understanding should auto populate the keywords. And they should appear on my page source, meta keywords.
Thanks in advance.
Cheers,
Furion
I have installed the plugin . I edited the title to overwrite the general setting. Everythin went fine but…How do I know it actually works? thank you
Thanks for your mail reply I appreciate
How do I add the titel of the page into the description?
love this new plugin. thanks mate
hello there,
I fund another plugin which will use a posts tags as keywords and that seems very nice to me. can that be included with your plugin too? can you have a look at its features, maybe you can improve your plugin too? here is the link: http://www.maxpower.ca/wordpress-plugin-tags-in-the-head/2006/04/17/ as I am still unsure which plugin fits my needs better… yours also works for categories I am not sure about the other plugin…
Kaf,
When I upload and attempt to activate the plugin, I get this error message:
Warning: Cannot modify header information - headers already sent by
(output started at /usr/www/users/kovalik/wp-content/plugins/head-meta-desc.php:77) in /usr/www/users/kovalik/wp-admin/plugins.php on line 15
I looked in plugins.php but can’t make sense of it. The blog I am woking on is http://dankovalik.com
WordPress vers 2.0.3
For some unknown reason, your webserver is somehow converting your plugin download into an html source code file, containing useless gibberish. Same problem also occurs with zip file. It however loads into a new browser window as a true php script file if you do a Save > Target As… This problem occurred with both MSIE and Mozilla.
It took me a while but I finally accomplished the task of getting the meta php file into my plugins. Now am I to understand that Tagline, description and keywords are generated automatically by the excerpts on my page and I really dont have to enter anything. Most of what I would have entered is what is on my pages. Please respond and let me know if this is true. Will search engines pick up some of that information even if I am not logged on or do I have to change the defaults for this to happen. Thank you so very much for this information as you helped a greenhorn accomplish this task. Thumbs up to you
Thank You
Ted user id (Schreech)
Unfortunately, I don’t know if I can use this plugin. It’s causing problems with wp-admin. When I logout, it goes to a blank white page that contains no source code instead of the normal log-in page, and it simply fails to logout. If I return to wp-admin page, the dashboard page appears as if I never logged out. The blank white page issue also sometime occurs when I edit a post. When I deactivated the plugin, the problem went away.
Works perfectly, and performs as advertised. Excellent plug-in!
Awesome plugin. Just installed and it takes me more than 30 minutes to get things, but still i fails on getting Meta Desc on Categories and works well in single post. Any help.
thanks, great plug-in
Hey Kaf,
Congrats for you great Head META Description. I’m wondering if the plugin writes anything in the wp_postmeta table in the Wordpress DB?
regards,
A really useful plugin, thanks for this.
Unlike some others here I think metas are still useful.
This is great - thank you!
I’ve tried 4 other meta plugins, but this one is definitely the best.
I really like the fact you can tailor it for your own use. Stuey
Seo rulez, thansk for share this plugin
Thanks for the simple and easy plugin.
Thanks, great plugin
Good plugin—thanks for sharing. Nice, simple, useful.
I’ve installed it, but when i look at my posts, there are now 2 content decriptions showing - one from the options page, and one by the plugin. How do i get the options one to stop apprearing? Thanks. (I’m not a PHP programmer)
Irene, check you header.php template file and you can probably remove the extra meta description tag.
I just installed the plugin, and it doesn’t add the description meta tags in any of my posts. I checked like three times and nothing. Can someone help me?
I use in my blog thanks for share you job
have a goog day.
Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/math-comment-spam-protection.php:1) in /wp-admin/inline-uploading.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/math-comment-spam-protection.php:1) in /wp-includes/pluggable-functions.php on line 269
???
help me.
Ok. I have already fixed this. It was my fault.
Hi,
I’m a fairly new Wordpress user, and I’m not quite following how to set a custom description for the post. I have Wordpress 2.0 and have installed your plug-in. Should I be seeing a custom field choice when I edit my post called description? I don’t see it; the only choice I see in the custom field dropdown is keywords, from another plug-in I have.
Hi Kaf
First of all thank you for sharing such a wonderful meta tag plugin software to everyone. I’ve read the remarks given by other members and I decided to download this plugin for my meta tag purpose.
Shy to tell you I have no knowledge on HTML, I’ve activated the plugin from the admin panel, I checked on my frontpage and post page, I don’t see any meta description at all. Do I need to add any coding on my html page? Please tell me how and where to integrate all this necessary task.
Appreciate your help so much.
Regards,
Vyim65
Hi Kaf
The problem has been fixed, meta tag description automatic created for the first 20 characters on each post.
When I look at the HTML page, the default meta description still exist on frontpage and post page, can I remove it totally?
I need to know if there anyway to create a custom meta description instead of plugging automatically from the first 20 characters?
Thanks
Vyim65
Thanks so much for this plug-in. It’s made a world of difference!
EVP
I am getting my blog together and want to just say this plugin is awesome! Thanks.
James
Nice Plugin…
One fix…
Use htmlspecialchars() to fix quoted text. Word. Looks like…
} elseif(is_category()) {
$category = $wp_query->get_queried_object();
$description = trim(htmlspecialchars(strip_tags($category->category_description)));
} else {
$description = (empty($default_blog_desc)) ? trim(htmlspecialchars(strip_tags(get_bloginfo('description')))) : $default_blog_desc;
Hi Slipgrid thanks for the extra code.
Hi, It appears that the plugin has adverse reactions to Windows Live Writer
I am having some problems with this plugin,
for some reason when I installed it, and activated it it will take my homepage Meta Description and add that first, then the 20 words after that.
Is there a way to only have first 20 words in the blog, rather than having the homepage meta description and 20 words?
Thank you!
Excellent plugin, makes the engines happy and me too. Congratulations!
thanks for the very useful plugin…
This looks like an excellent plugin which would solve my SEO problem but I have just tried it out with wordpress 2.02 and it fails to work for categories. I look forward to an update - as it is an extremely useful tool.
Hi,
I’ve uploaded the plugin and activated it. But when I checked my site, there’s nothing happen. It stay the same as before pluging-in this awesome plugin.
Pls comment.
Thanks and appreciated.
^ Try reinstalling your theme. It worked for me.
Hey i installed your plugin and it works awesome! Thanks man! :D
I have used the plugin on my website http://www.myrddin.de/ for quite some time now. You have done a great job at it - Thanks.
With the Recent upgrade from Wordpress 2.0.4 to Wordpress 2.0.6 the plugin stopped woring for me. The
function wphead(); is still being called in the Theme, but it no longer seems to produce any output, not even the default description.I have tried the option the poster above mentioned but in no other theme the plugin seems to work.
Hi…I have installed Head META Description, but how do I actually use it, and how I know if any changes are made?
I have read through the comment here, but still do not understand how to use it.
I also looked through the page source, and I just only see the meta tag for description. How do I add meta tags for keywords?
>>(the $custom_desc_key variable defines the key; your custom field value would be the description for that post or Page).
I’m using this function on a WP page, and it isn’t working. It’s still showing the first sentence of the page both in the source and in Google. Any ideas?
Hi, I would love to be able to use this as I think it’s fantastic. However, looking at the source page, I don’t think it’s working. Can anyone please tell me whether I can use this? Btw I’m using Wordpress 2.1 and the url is http://www.pssss.com/ Many thanks!
I believe this plugin no longer works on latest Wordpress versions.
Hey i installed your plugin and it works fine! Thanks a lot! :D
Hi,
I’m a fairly new Wordpress user, and I’m not quite following how to set a custom description for the post. I have Wordpress 2.0 and have installed your plug-in. Should I be seeing a custom field choice when I edit my post called description? I don’t see it; the only choice I see in the custom field dropdown is keywords, from another plug-in I have.
Great plugin, makes the search engines happy. Thanks for sharing.
Thanks for your plugin!
I did not able to find any plugin for making custmized title tag, however Ithink title tag is more important, why it is not developed? any idea?
This is great! Will also try the code from Slipgrid. Thank you!
Hi - First of all, great plugin it does just what it says on the tin… however, I have a site where I need to add my h2 info to the Description Meta data, is this an easy hack? Can someone post up a snippet to address this? Many thanks.
I use Textile on my sites and the description would include the unformated textile codes. So I made a quick and dirty edit. At line 48 add:
// My edit to make it textilize the text before stripping the tags
require_once( “textile/classTextile.php” );
$textile = new Textile;
$text = $textile->TextileThis($text, false, false, false, false);
// End my edit
And the Textile codes is formated as HTML before the tas are stripped. There is most likely a better, easier and faster way to do this, but I just started using Wordpress. Please enlighten me if you know a better way.
PS: I use this textile plug-in: http://huddledmasses.org/category/development/wordpress/textile/
I’m giving the plugin a try. Thanks.
Seems to work fine in WP 2.1.1. Thanks!
Thanks for a great plugin! I have been looking for something simple that does this one thing — Ultimate Tag Warrior takes care of the Keyword meta tags.
Thanks for the plugin.
Can you guys add meta- keyword in this plugin?
Let me know if any pugin available related meta-keyword, thanks.
Thank you for the latest release, fixed my problem with Categories.
I can´t get the description to show in Pages. Newer WP releases don´t have an excerpt for Pages.
How can we fix this? All new pages now have empty descriptions!
Maybe with the optional fields ?
I feel kinda silly replying to myself:
To get the description working on pages you just need to use a Custom Field named “description” and then enter your description.
Great plugin. Now my site is in first TEN in google - for “programy partnerskie”.
Hi all,
I’m so sorry, but I not can realize this plugin. I have try to use this an my first installation of Wordpress. I want use it for a catalog of Information on LexiForm. Is a readme in german available? Anyone use it for a german blog an can help me to use this very fine plugin?
Hi Kaf,
I’ve installed head meta plug in but im not sure if its working properly. my source is something like this :
SkyBiz Redress Program I GoGoUpdates.Com
Pls advise.
ops, the code doesn’t show it. anyway, its at http://www.gogoupdates.com . Pls advise. Thanks
I’m having problem with this plugin, my WP is 2.2.1: seems like descriptions aren’t shown.
Anyone is having the same problem?
In WP2.2.1 I get the following error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Server/Account/MyDir/Blog/wp-content/plugins/HeadMeta.php:61) in /Server/Account/MyDir/Blog/wp-content/plugins/contactforms/cforms.php on line 66
My site is at http://blog.scoop0901.net.
Thanks for any info or assistance!
I just implemented your plugin.
It works great. Thanks a lot.
On posts, pages and homepage it is perfect. Does not show meta description in categories (I am using K2 theme). I do not need meta there anyway. I am using your plugin only for SEO purposes and I have a no index on the categories, so it is not a problem.
perfect, it’s a must have plugin. I hope it will work on my site
Great - simple to use, does exactly what it says on the tin - thanks for a brill plugin.
Hi, i’m new to wordpress, comes from blogger.com
I can’t found the way uploading files into my wordpress.com account
Is there any guide will help me?
Thanks,
I can´t get the description to show. I am using WP 2.2.1
My website - notsonews.com - is powered by wordpress 2.2.1 and this plugin works like a charm. I have posted a “thank you” message and a “do follow” link towards this page on my about pages. Many Thanks!
I’m using wp 2.2.1, activated the plugin, made sure there’s a wp_head() in header.php but still doesnt work, am i missing something here?
hello,
thanks for plugin !
as i’m using htmlentities, i thougt, and maybe i was wrong, id’ beter add this function:
function reverse_htmlentities($mixed)
{
$htmltable = get_html_translation_table(HTML_ENTITIES);
foreach($htmltable as $key => $value)
{
$mixed = ereg_replace(addslashes($value),$key,$mixed);
}
return $mixed;
}
and then use it whithin head_meta_desc():
$text = trim(strip_tags($text));
reverse_htmlentities($text);
$text = explode(' ', $text);
hm, was i right?
(still having a problem with styles i’m using within tags, but, i do not really care).
well anyway, thanks again
First, thanks for you hard work on this plugin. I have a question though. Do we have to remove the empty meta tag for Keyword and Description. I still seee them there.
and the new keyword and description tag.
thanks.
Will this plugin work with Wordpress 2.3? =/
@Ryan: Yes, I tried it with Wordpress 2.3 and it seems to work.
Thanks for this plugin.
But it one thing that im thinking about. When I look through the serp, my site shows the date like May 9th, 2007. Is there any way to fix so your plugin doesn’t take the date with it?
Thanks. I was not sure, if it works with the german WP. My english isn’t really good. So it was a hard work to realize it. Now I’m finished and have many sweat.
Now waiting for the next version of WP to start again.
In the new version of wordpress is include this function or use wpseo plugin
Thank You for plugin !
Now i’am used it :)
Thank You!very good
thx! this plugin helps me a lot to optimise my blog!
Thank you for all your work. This plugin it works just great.
Had it installed for a while and still not working - any advice welcomed…