WordPress Tip: Reorder your Title Tag

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.

  1. Open your header.php theme file (if you don’t have one, open index.php or whatever one has your <title> tag)
  2. Look for:
    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    (or something similar) 
  3. Replace it with:
    <title><?php wp_title('&raquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

The first wp_title() argument is the separator character.  I like &raquo; (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.

51 thoughts on “WordPress Tip: Reorder your Title Tag

  1. It should be noted that the new ‘right’ optional parameter is new to WordPress 2.5, so you must be using it to do it this way.

    If you have an older version of WordPress, use the Optimal Title plugin instead.

  2. good call Mark.

    I’ve been using the optimal title plugin for a while now to get the same effect as what you’re showing.

    it’s really helped in the search engine results, I feel.

    I actually have a file dedicated to my because of how many different variations I have for it.

  3. In addition to SEO, starting with the more specific title is also good for any situation where titles get put in a list — lists of articles, bookmarks, tabs, etc. — because it makes the important part easier to spot while skimming.

  4. Another SEO fix will be include a tag such that when there is no title, the blog name show up first, like on the home page or paginated pages, archives, search results etc. Code below.


    <title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' »'; } ?> <?php bloginfo('name'); //SEO FIX ?></title>

  5. I use the all-in-one SEO plug in – I must admit that I’ve not looked into it too much to be honest, but I think I’ll optimise my titles at some point today, as they are one of the most important elements of SEO.

    Thanks for the tips 🙂

  6. Carly, your right, titles are currently, and have always been, the most important tag,,, and I also use the same plugin. I have always taken out the name of the site and included the appropriate key words as needed. The title is the first thing viewers see in the search engines so I made that line as appealing as possible.

  7. RE: Jack –

    I changed all my titles to post/page name | sitename | myname – as I already try and make the titles of the posts I want people to find Keyword rich, and I want my own name to feature higher in the SERPs.

    I shall have to wait and see if this works in the way I hope!

  8. And while you’re at it, you could also simply replace with your own blog name. It will reduce the amount of queries to the database by one for every pageview.

  9. Personally I use ‘%post_title% presented by %blog_title%’ or ‘%post_title% on %blog_title%’ via the All In One SEO plugin for WordPress.

    This makes the title element a sentence that is easier to read and probably scores lots of points for accessibility. I read somewhere that page readers (for the blind) read the separators that so many of use have used in our title tags.

    For example this page’s title would be read out, “wordpress tip colon reorder your title tag left-pointing double angle quotation mark mark on wordpress.” How annoying is that?

    @Lodewijk : Top tip – I like that.

  10. I have changed the header.php file according to this tip and then realized that nothing has changed because I am already using the All in One SEO plugin.

    ;-(

  11. Did Matt Cutts say anything about the double arrows? Ages ago, there were issues with handling these in search indexes, but that seems to be resolved. Many visually impaired users complain about these and say they do not meet web standards. Personally, I’d love to see them gone and replaced with the traditional dash, so I’m never keen on recommending their use. I like things simple.

    Thanks for the info on the new parameters on the tag!

  12. I have removed the blog/website name from my title as I think the fact that all pages have it is not ideal.

    What do you think? Is this a good idea?

    cheers
    Tony

  13. I wanted to ask: what is the difference between yours:

    And this one I found on another site:

    |

  14. 78. Good blog! I truly love how it is simple on my eyes and the data are well written. I am wondering how I could be notified when a new post has been made. I have subscribed to your RSS which must do the trick! Have a nice day!

Comments are closed.