If you’re a Wordpress Content Management System user, and you would like to make your page titles SEO friendly without installing any plug-ins or modifying your website too much, then this article might be for you. All it requires is a few lines of PHP in your header.php file.
1 2 3 4 5 6 7 8 | <title> <?php if (is_single() || is_page() || is_archive()) { wp_title('',true); } else { bloginfo('name'); echo(' — '); bloginfo('description'); } ?> </title> |
And now let’s look at what we have above..
First we have our HTML/XHTML opening <title> tag, and then we of course have our opening PHP tag <?php. Nothing much to talk about until we get to the next line which happens to be the meat and potatoes of the tutorial..
1 2 | if (is_single() || is_page() || is_archive()) { wp_title('',true); |
This if statement basically asks: “Is the page I’m displaying a single post (single.php), a page (page.php), or an archive file (archive.php)? If so, display the title of my post, the title of my page, or the title of my archives listing as the title of my website.
1 2 3 | } else { bloginfo('name'); echo(' — '); bloginfo('description'); } ?> |
Next, we have an else statement. Basically the actions performed in the curly braces after the word ‘else’ are executed if the page we’re displaying is not a single post, a page, or an archive listing.
So then, what’s left you ask? The home page, or index page if you’d prefer. In the example we’ve used, we used the Wordpress template tag bloginfo to display our website’s name followed by our website’s description as set in our general Wordpress settings. So then, if we were to use this bit of code on JungleJar.com for example, our page title when we visited the index page (www.junglejar.com) might be: JungleJar.com – Web Design & Development. JungleJar.com would be the name and “Web Design & Development” would be the description. If we were viewing a single blog post, this one for example, our page title would be: “Wordpress Tutorial: Make Your Page Titles SEO Friendly”
The logic behind the madness is this: Search engines put a lot of emphasis on what your website title / page title / etc is, and the more your page title matches the content on the page itself, the more the search engines find your website to be trustworthy. The more trustworthy the search engines find your website to be, the more apt they are to crawl your website for keywords, and if the page titles match and use the keywords and the keywords match the page content, your website will have become that much more optimized and loved by the engines that be. This is an extremely short explanation on the importance of page titles and how they relate to SEO, but it certainly points you in the right direction.
I hope this helps some of you, and remember; Even if you do use a plugin such as All In One Seo, which is a fantastic SEO plugin for Wordpress, you can still use this little bit of code displayed above. I actually prefer to do this than set any options for the titles in the plugin configuration.



Im not very savvy when it comes to SEO so this was a great read for me. Do you know if it might by any chance conflict with the All-In-One SEO plug-in?
Yeah, you can use it with that plugin. If you’ll notice, I mentioned at the end of the article that there are no compatibility issues.
I myself use it with that plugin just fine.
What about the issue with Google Webmasters counting both the comments page and the single post? Your post doesn’t seem to address that problem.
Example:
http://www.leoraw.com/blog/2009/03/11/seaweed-for-fighting-disease/comment-page-1/
and
http://www.leoraw.com/blog/2009/03/11/seaweed-for-fighting-disease/
have the same description.
I added SEO for Paged Comments plugin, but I’m still getting duplicate description tags in Google Webmasters.
Well, this was meant to be a brief tutorial as compared to the other Wordpress tutorials I’ve written for JungleJar. With this said, I didn’t even think to mention anything about comment pages. However, very few blogs/websites display comments on a totally separate page.
For the blogs/websites that do use separate comment pages, one could whip up a little bit of extra PHP code consisting of not a lot more than an if else statement.
As far as Google Webmaster nailing you for duplicate description tags..well, chances are Google Webmaster is also nailing you for duplicate content in general, because you are using the same heading (post title — not talking about the actual meta tag page title) on both the post and comments page. Most likely the rest of the search engines that matter are doing the same thing. So, with that said, you might want to display your comments on the same page as your post. Otherwise you’ll be running into SEO issues whether you use the code snippet I provided in this tutorial or not.
I think this is an issue with the new commenting on Word Press 2.7. Another approach is here (but I think this means comments don’t get included for search engines):
http://blog.kaizeku.com/wordpress/prevent-wordpress-27-duplicate-content/
I might try this method instead of the plugin, which doesn’t seem to work.
Yeah, I would try that method you found. The code he/she wrote seems a bit excessive, but it looks like it’ll work just fine, and yeah, your comments won’t get included in search engines. This is a good thing though for the most part.
Thanks for looking at it. I’m hoping the WordPress developers address this issue with the comments page in the future, because I’ve had a lot of fun playing with the new nested comments.
I don’t see the Wordpress development team doing much more than adding an option to automatically have the comments page ignored by search engines when they crawl the website. It’s like with any other feature you add to your website.. whether it be a plugin or a widget, a lot of times there are going to be problems with these software bits you’ve added to your blog when it comes to SEO, html/xhtml/css validation, or both.
One example of this is the Feedburner E-mail plugin. Unless you know how to tweak the code up, your website is not going to validate, heh.
I’m having the same problem as Leora with a url of my blog post and a url with /comments-page1 and comments/page-2. The comments page was only created once a 2nd page of went live.
As I’m not very good at wordpress, a simpler option than that heavy code would be nice.
The SEO page titles have nothing to do with the paged comments feature in Wordpress.
If you’re talking about the duplicate content problem that Leora was having specifically, then all I can really say is I’ll be writing a new tutorial on JungleJar soon to cover the issue. This tutorial was written before the comment paging feature was added to Wordpress.
Sorry guys.
Looking forward to hearing what you (Admin) have to say on the subject.
I fixed the comment page two problem by using the canonical plugin.
Also, I added this to my theme code, in the header:
else if (is_home()) {
bloginfo(‘name’); echo ” – “; bloginfo(‘description’);
if ( $paged < 2 ) { } else { echo (‘ Page ‘); echo ($paged);
}
That basically says “if this is the home page, add the blog name, the blog descripition; if $paged is 1, do nothing, if $paged is more than one, say Page 2 (or 3 or 4 or whatever).”
You really have to be comfortable with PHP to add that “if” line, but you can add anywhere there might be a Page 2, like a category.
Very nice addition to the code. You should write a tutorial for JungleJar ;)
Hmmm. Nice one