Modify the Page Title of a WordPress Post

I’m by no means a SEO expert but I roughly know what I’m doing and I’ve always thought that the default way WordPress displays the page titles for a post is a bit the wrong way round. A post should be optimised for the content on that particular page as opposed to the name of the blog which should mean that the post name should precede the blog name in the title tag, e.g.

<title>This is the post title » Blog Name</title>

You can do this by modifying a line of code within your header file. Go to:

WP root > wp-content > themes > theme_name > header.php

Open this file and replace the code within the title tags with the following:

<title><?php wp_title(‘ ‘); ?><?php if(wp_title(‘ ‘, false)) { echo ‘ &raquo;’; } ?> <?php bloginfo(‘name’); ?></title>

And that should be it!

About the Author

I'm a web developer based in the East Midlands, UK and if I keep up the current rate, I might have developed 3 million sites by the time I retire