WordPress, by default, creates <title> tags that look like this: <title>Yoursite » Your Post Title</title>. Many people want to use <title>Your Post Title » Yoursite</title> instead, to give more importance to the mutable part of the <title>. There are plugins to do this, but I’d like to show you how a simple change in your theme can accomplish this task. Caveat: this only works in WordPress 2.5 and above.
- Open your
header.php
theme file (if you don’t have one, openindex.php
or whatever one has your <title> tag) - Look for:
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
(or something similar) - Replace it with:
<title><?php wp_title('»', true, 'right'); ?> <?php bloginfo('name'); ?></title>
The first wp_title()
argument is the separator character. I like »
(which looks like: »). The second argument is whether to echo (print to the browser) the title, or to return it. We want to print it, so we put true
. The final argument is where the separator should go… on the left or on the right. We want right, so we put "right"
. Simple enough!
Update: I got confirmation from Matt Cutts at Google that this is better for SEO.