Design Simply

Simplicity in design, photography & code.


SEOify Your WordPress with Description & Keyword Meta Tags

Ever wonder how to SEOify your Wordpress install? Here’s the code I used in my Wordpress theme to use custom fields for description and keywords meta tags. The down side to using this method is that you have to modify it for any new customized meta tags you want to use. I really only wanted to customize the description and keywords meta tags, so this worked out great for me.

<?php
if (is_home()) {
   $description = "Default description of this website.";
   $keywords = "default, keyword, list";
} else {
   $description = get_post_meta($post->ID,'description',TRUE);
   $keywords = get_post_meta($post->ID,'keywords',TRUE);
}
if ($description) {
   echo "\\t<meta name=\"description\" content=\"$description\" />\\n";
   }
if ($keywords) {
   echo "\\t<meta name=\"keywords\" content=\"$keywords\" />\\n";
   }
?>

Here is another similar method:

<?php
  $pagetitle = get_post_meta($post->ID,'pagetitle',TRUE);
  $description = get_post_meta($post->ID,'description',TRUE);
  $keywords = get_post_meta($post->ID,'keywords',TRUE);
  if (empty($pagetitle)) {
    echo "<title>";
    wp_title('');
    echo " - ";
  } else {
    echo "<title>";
    if ($pagetitle!='') {echo "$pagetitle - ";}
  }
  bloginfo('name');
  echo "</title>";
  if (!empty($description)) {
    echo "\\t<meta name=\"description\" content=\"$description\" />\\n";
  }
  if (!empty($keywords)) {
    echo "\\t<meta name=\"keywords\" content=\"$keywords\" />\\n";
  }
?>

Other meta tags, like character set, are hard coded into the main header.php code because they are the same on every page.

You can find more information about Using Custom Fields on wordpress.org. There are several meta plugins listed on wordpress.org, and a search for custom fields plugins wordpress on Google will return even more options.

Add to your del.icio.us Add to del.icio.us Digg this storyDigg this

7 Responses to “SEOify Your WordPress with Description & Keyword Meta Tags”

  1. Book Review: Professional Search Engine Optimization with PHP by Sheri Bigelow of Design Simply Says:

    [...] SEO for WordPress blogs [...]

  2. Mike Says:

    Thanks a bunch, I will definately be using this :)

  3. J.R. Jackson Says:

    Excellent, thanks.

    J.R.

  4. Blog Hoster Says:

    Thanks for the share.Will come in handy:)

  5. kensty Says:

    Great article! I’m loving your website;

  6. shoudlnt i try it? Says:

    thanx for a great post mate

  7. keywords software Says:

    To be able to get the best search engine ranking you will need to do a keyword research analysis to determine what keyphrases people type in for when they are researching online. A nice keyword software will make things easier. It also helps if the niche you are researching is one that you are fanatic about.

Leave a Reply



Copyright © 2000-2010 Sheri Bigelow. Proudly powered by WordPress and hosted by bluehost.
Log in. Valid XHTML 1, CSS 2. Entries (RSS) and Comments (RSS).