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.
April 17th, 2010 at 4:23 am
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
April 18th, 2010 at 3:53 pm
It’s been a while since I scan a truly glorious blog post. Not solely well written however relevant. Congratulations.
April 20th, 2010 at 10:50 am
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.
April 21st, 2010 at 8:08 pm
Really good post. As usual…
April 22nd, 2010 at 7:43 am
Really good post. As usual…
April 28th, 2010 at 10:12 am
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. -
May 1st, 2010 at 1:48 am
WordPress is the best blogging platform ever. It is much better than Typepad and blogspot.,,~
May 2nd, 2010 at 8:01 am
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?
May 14th, 2010 at 11:42 am
good idea!
May 16th, 2010 at 5:59 am
I’m doing some research in this field and your post has helped a lot, thank you.
May 18th, 2010 at 9:34 pm
A very good marketing strategy is very important in promoting your products both online and offline.,~;
May 20th, 2010 at 6:14 am
Thanks, I’ll look into them.
May 24th, 2010 at 7:50 pm
Copyrighting is very important specially if you wrote original articles both online and offline.
June 15th, 2010 at 10:47 pm
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.