Optimizing Word Press Title Tags
Many users of Word Press have found issues with their title tags that render their links poorly in the search engines.
These are the main problems that users wish to fix about the title tags are:
.) Place post title before the blog title
.) Remove the dash (or ») when there is not post title.
.) Users wish to remove the “»” altogether from the title tags.
Let’s start with the first issue of changing the order of display in the Word Press title tags. For SEO purposes, you would be better off having the title of your actual post appear in the TITLE tag first, like: “Post Title » Blog Title” rather than the other way around.
To make this change, go into the theme editor of your Word Press admin and click into the heder.php file. In the top of the file look for the section that starts with “<title>”.
First, remove everything from between the <title> tag to the </title>. This should result in your TITLE tags looking like this:
<title> </title>
Next, add the following lines of code into their own lines between the TITLE tags so that your TITLE section looks like this:
<title>
<?php wp_title(); ?>
<?php bloginfo('name'); ?>
</title>
Now if you go back and look at your site’s pages you will see that we have reversed the order of the TITLE tag, placing the post title in front of the blog’s title. However, this is still not perfect, as you will see that the the “»” appears in front of the post title on your post pages, rather than in between the post title and the blog title as it is intended.
To fix this issue, go back to the theme editor for the header.php file and again find the TITLE section of the file near the top.
We are going to again add some code to that section of the header.php file. Add the following code to TITLE section so that your TITLE section looks like this:
<title>
<?php wp_title(); ?>
<?php if(wp_title('', false)) { echo ' » '; } ?>
<?php bloginfo('name'); ?>
</title>
You will find that this almost solves the problem, by placing the “»” in between the post title and the blog title where it belongs; however this still leaves another instance of the “»” at the very front of the TITLE tags on the blog pages.
To fix this we have to make another small change to the TITLE section of the header.php file from the theme editor of the admin panel.
The title tag we’ve been editing this far is actually abbreviated PHP code. There are some definable variables that are being allowed to fall back to their default states as defined by the main Word Press code. Because we haven’t indicated for the script to act otherwise, the script is falling back to its default behavior.
To fix this issue, we are now going to change the first line of the TITLE section in the header.php file to the following:
<?php wp_title(' ' ; ?>
Your entire TITLE section of the header.php file should now look like this:
<title>
<?php wp_title(' '); ?>
<?php if(wp_title('', false)) { echo ' » '; } ?>
<?php bloginfo('name'); ?>
</title>
This will now have your TITLE tags acting the way you want them to, with the post title being listed first and the blog title listed second. This also removes the separation from the title tags, when there is no post title for pages like the home page.
The only thing left is to change the separator from the “»” to another symbol.
To do this, you have to change the separator in the new TITLE section of your header.php page.
In your new TITLE section, you will see the following (I have bolded the part you are looking for):
<title>
<?php wp_title(' '); ?>
<?php if(wp_title('', false)) { echo ' » '; } ?>
<?php bloginfo('name'); ?>
</title>
You need to change the “»” to any other character that you wish. You may use a character entity chart to select a different separator, or you can go with a simple pipe (|) character the choice is up to you.
On my blog, I have chosen to use a simple pipe delimiter format like this:
<title>
<?php wp_title(' '); ?>
<?php if(wp_title('', false)) { echo ' | '; } ?>
<?php bloginfo('name'); ?>
</title>
Please let me know if there are any other issue that you find with the TITLE tags in Word Press, and I will see if I can help you solve them.







September 23, 2006 @ 8:15 pm
Zach, great article! I have a Wordpress Title related question…how do you include the Category name in the Title? The closest I’ve come to finding out is this Wordpress support link ( http://wordpress.org/support/topic/33392 ). When I add the_category (etc.)I get the same extra info. in the Title and the person describes in the support forum.
Thanks,
Brendan
September 24, 2006 @ 12:06 pm
Brendan,
Unfortunately there is no perfect way to call the category to the title of your Word Press blog for all situations. There are several ways that the info can be called, but they may not be exactly what you are looking for.
To show the category for every page in your blog (including the home page) you can try this:
The good thing about this solution, is that it will show the category name for all individual posts, as well as all category pages. The bad thing about this solution is that it will also show the last category posted to on the home page.
If you wish to only show the category name on actual category pages use this:
The good thing about this solution is that it will not show anything in title for your home page. The bad part is that it will also not show the category name on each individual post.
Aside from these two options, there really is no easy way to get the best of both worlds. I suppose it would be possible to query the database for the current, or associated category, and then replace the category ID with the category name. However, I do not want to post such a hack here - the follow up and support for me would be too much.
If someone else reading this post would like to give it a try that would be great. I would be happy to post your outcome with a link to your site.
Hope that helps!
September 24, 2006 @ 4:03 pm
Thanks Zach! The first solution does what I was looking for except for the homepage issue. I want to put the categories in the title because, as I understand it, the title tag is important for SEO and my category names are good “keywords” to use. Now I’m wondering if having changing title tags for the homepage would be a bad thing in Google’s eyes? (I do think it looks bad for visitors to the homepage to see a stray category name in the title of their browser.)
Brendan
November 14, 2007 @ 7:17 pm
[...] Works like a charm. Thanks to Zach. Posted by Craig Filed in Web Tags: seo, wordpress [...]
November 28, 2007 @ 8:34 am
Hi.
Good design, who make it?
December 24, 2007 @ 3:14 am
small-for-gestational-age infant
May 17, 2008 @ 12:31 pm
[...] more information on optimizing other blogging software, please see Optimizing Blogger Title Tags, Optimizing Word Press Title Tags and Optimizing Blogware Title Tags. Bookmark It Hide [...]
May 17, 2008 @ 12:32 pm
[...] to a very large response to my article about optimizing Word Press title tags, I figured I would write a few more articles describing how to optimize the title tags of other [...]