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.
Mentioned in Book Review: Professional Search Engine Optimization with PHP by Sheri Bigelow of Design Simply
Hi all great information here and good thread to comment on.
Can I ask though – how did you get this picked up and into google news?
Very impressive that this blog is syndicated through Google and is it something that is just up to Google or you actively created?
Obviously this is a popular blog with great data so well done on your seo success..
Awful lot of code. Not to be rude, but I’m sure you could simplify things down a bit.
Thanks a bunch, I will definately be using this :)
Excellent, thanks.
J.R.
Thanks for the share.Will come in handy:)
With the new release of WordPress I don’t even think this is needed anymore. Good post for those running older versions of WordPress.
i dont understand on the description part. is there any example on a good meta description? same goes with meta keywords. is it enough to just put on %cats% and %tags%?
Great article! I’m loving your website;
Sorry to be off topic, but I like your posts and I wanted some feedback for my blog. I have a hard time writing, but I do want to share my experiences. Am I stuck between a rock and a hard place? Or should I just do it?
thanx for a great post mate
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.
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
It’s been a while since I scan a truly glorious blog post. Not solely well written however relevant. Congratulations.
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.
Really good post. As usual…
Really good post. As usual…
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. –
WordPress is the best blogging platform ever. It is much better than Typepad and blogspot.,,~
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?
good idea!
I’m doing some research in this field and your post has helped a lot, thank you.
A very good marketing strategy is very important in promoting your products both online and offline.,~;
Thanks, I’ll look into them.
Copyrighting is very important specially if you wrote original articles both online and offline.
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.
Worked for me thank you!
Optimizing meta tags is important but there are a dozen plugins that do that for you, so why bother doing it yourself? Good post, though.