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.





March 2nd, 2008 at 10:51 pm
[...] SEO for WordPress blogs [...]
July 11th, 2008 at 10:45 am
Thanks a bunch, I will definately be using this :)
July 11th, 2008 at 11:46 pm
Excellent, thanks.
J.R.
August 5th, 2008 at 12:53 pm
Thanks for the share.Will come in handy:)
January 24th, 2009 at 8:22 pm
Great article! I’m loving your website;
December 16th, 2009 at 10:05 am
thanx for a great post mate
March 8th, 2010 at 6:50 am
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.