By default, WordPress page title for single post is “BlogName » Blog Archive » Post title“. This is not a good page title in terms of SEO. I will show you how to create a better page title for WordPress blogs.
Table of Contents
Why post title first?
A better page title is one with post title coming first before the site name. There are few reasons for doing so:
- Search engines read page title and use it as linking text in search results.
- Search engines only read first few words of page title.
- Search engines bold search query keywords in page title.
- People are interested on your post title, not your site name.
Which file to edit?
We will need to edit the “header.php” file in WordPress template folder. The line of code is:
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
bloginfo(‘name’) shows your WordPress blog name.
wp_title() shows your post title with leading default separator text (‘»’)
is_single() checks if the page is a permalink page (single post).
Change WordPress page title using wp_title template tag
We can still use the WordPress template tag wp_title() for reversed blog name and title. Simply replace the default line of code with the following code:
<title>
<?php wp_title(' '); ?>
<?php if(wp_title(' ', false)) { echo '--'; } ?>
<?php bloginfo('name'); ?>
</title>
The output will be “Post title — BlogName“. You can define your own separator text by replacing the “–” in the code.
Example: <?php if(wp_title(' ', false)) { echo '»' ; } ?>
[Reference: WordPress Codex]
Change WordPress page title using Optimal Title plugin
The previous method is quite confusing for some beginners. For my sites, I am using a simple and easy wordpress plugin called “Optimal Title“.
Optimal Title is an old plugin but it is still working fine with current WordPress version. In fact, it is copy of wp_title() but it shifts the separator text from left side to right side.
How to use Optimal Title?
After installing the Optimal Title plugin, simply replace the default line of code in header.php with:
<title><?php optimal_title(); ?><?php bloginfo('name'); ?></title>
It will show “Post title » Blog Name” as page title. You can define your own separator text by adding parameter to optimal_title().
Example: <?php optimal_title(' -- '); ?>

WordPress 2 : Visual QuickStart Guide
Advance: Show blog description on the main page, but shows post title on single pages
The following code shows the page title as “Blog Description at Blog Name” at front page, but shows “Post title at Blog Name” on single pages.
<title><?php optimal_title('') ?> <?php if (is_home()) bloginfo('description'); ?> at <?php bloginfo('name'); ?></title>
bloginfo(‘description’) shows your blog description.
My two cents
Perhaps you don’t care about the page title but trust me, it is a simple and effective way to increase your site ranking, and visitor traffic!
We can use it in any version WP ?
or just for the 1.5.2 ?
It should work with WP2 too. Test it and tell me your result pls :)
the TITLE optimization is a must. h1 h2 are all useless. the TITLE is the main factor in getting traffic from search engine.
Yes I made the template change directly to my blog using WordPress 2 and it works!
But don’t just cut and paste the text given by liew because WordPress changed the single quotes ‘ ‘ . Replace the quotes with true single quotes and it will work.
If anybody interested, I’ve assemble a list of plugins for optimizing keywords and description tags too. Although the emphasis on keywords is less these days.
Thanks LcF and Gaman, i will tried it out with my Blog…which will be up soon…hah!
alamak..!!!!something funky happened when i made the chages ,but i guess its got to do with what gilachess wrote.
Just to be clear, the code looks like this — cut/paste did not work as the single quotes and the dash are not clean ASCII:
Thanks! This worked amazingly. I hope I can get more hits now. I never thought about SEO with my wordpress, especially with the titles. My template must have been crummy to begin with. Thanks.
I’ve written some instructions for changing the behavior of wp_title to produce better page titles. This includes a method for removing the separator and also for removing unwanted spaces.
http://www.ardamis.com/2006/07/03/optimizing-the-syntax-in-the-wordpress-title-tag/
If I make these changes to my post titles..will I have to do 301 redirects or is the URL unaffected?
@Andrew Kelsall: you can keep the url (post slug) when editing the post title. no problem :)
Thanks, will get onto it soon…
hi Liew, remember me ? :)
I am helping my friend to setup a blog website recently, and I think this is a better solution for newbies… no programming knowledge require, just install the plugin. : http://wordpress.org/extend/plugins/all-in-one-seo-pack/
Cheers.
JAMES
@james: thanks for the plugin
Great post. Thank you.
One item that DaveS touched on. You should change the example code to courier or code text because when I copied and pasted it into my web file and uploaded it there was an error because the browser didn’t understand the apostrophes.
Some beginners may not be aware of changing the apostrophes and get stuck.
Thank you for this wonderfull tutorial. I been doing SEO on my site for a couple of week and thanks for your tutorial, I was able to edit my heading 1 or h1.
This is my blog that I edit with the help of your tutorial http://surforeo.com/prc/nursingboardexam/