features category image instructions category image Easily Editable Meta Description for Individual Pages

Posted on October 26, 2009 and last modified on October 26th, 2009.

SEO, SEO, SEO!“,  screams the Net wherever you surf these days. And one big area they will rave about when discussing Search Engine Optimisation [SEO], is making sure you use valid and well thought out Meta Descriptions.

The trouble with the basic WorPress installation though, is that it does not allow you to make much headway in this area. Yes, I know there are many plugins available to cater for this need, but just for moment, let’s NOT use a plugin for this.

By adding the following code to our little functions.php file, we can make it so that in all of your pages [not posts], you can write a valid, and more importantly, DIFFERENT meta description by simply writing in your excerpt box.

<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta name="description" content="<?php
      if (is_single() || is_page()) {
           # Single post / page.
           # Use the 'description' custom field.
           echo get_post_meta($post->ID, 'description', true);
      } elseif (is_category()) {
          # Category page.
          # Use category's description
          echo trim(strip_tags(category_description()));
      } else {
          # Default meta description
          # Blog's description
          echo bloginfo('description');
      }
?>" />

Related Posts:

No related posts found!

About the author

James has added 29 posts to this site so far...

Founder and co-admin at FreshlyPressed, James also runs and maintains many, many other sites including JamesICT which is very much focussed on WordPress and all of its little idiosyncrasies. He now lives in Brighton, England with his fiancée and writes novels in his spare time. His latest work, 'Procrastination Expectancies' is due out later this year - or maybe the year after that! [more...]

Other posts by James

Trackbacks/Pingbacks

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>