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.

22 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.

  8. website promotion software? Says:

    web marketing and advertising is undoubtedly more or less all about the range of other websites linking to you. when not having those backlinks to your site you are dead in the water. this became apparent to me soon after getting started with what is actually i think the most powerful semi-automatic one way link building tools available … promoting website

  9. Rodney Navo Says:

    It’s been a while since I scan a truly glorious blog post. Not solely well written however relevant. Congratulations.

  10. Bo Maker Says:

    This is often one in all the most effective blog posts that I’ve presumably ever read. It’s like a well-written paper. Your topic has relevancy, you’ve broken the topics down logically.

  11. Karma Fuhri Says:

    Really good post. As usual…

  12. Rick Sartor Says:

    Really good post. As usual…

  13. Kim Isidro Says:

    i am a newbie in Search Engine Optimization but i think that the submission of articles in article directories is one of the best ways to gain backlinks. -

  14. Erin Turner Says:

    WordPress is the best blogging platform ever. It is much better than Typepad and blogspot.,,~

  15. Web Design Consultant Says:

    Myself I am nub in PHP but how does this code compare to the Platinum SEO Pack Plugin offered a by the WP plugin directory? Any advantages or disadvantages?

  16. Learn speak hindi Says:

    good idea!

  17. Learn Wordpress Says:

    I’m doing some research in this field and your post has helped a lot, thank you.

  18. Ellis Gibson Says:

    A very good marketing strategy is very important in promoting your products both online and offline.,~;

  19. Josh Nicholson-internet marketer Says:

    Thanks, I’ll look into them.

  20. Caden Alexander Says:

    Copyrighting is very important specially if you wrote original articles both online and offline.

  21. Trena Barness Says:

    These kinds of posts are always inspiring, I prefer to read quality content so I pleased to find many good point here in the post, writing is simply great, thank you for the post.

  22. Emily Kirby Says:

    Worked for me thank you!

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).