Optimal Title Functionality Now in WordPress Core

I wrote Optimal Title three and a half years ago to help fix a blatant flaw in WordPress’s default usability and search engine optimization (SEO). Since then, the plugin has been downloaded by tens of thousands of people and written about by hundreds of bloggers. Soon, the plugin will become obsolete…

A Change in WordPress v2.5

As of the beginning of this year, a changeset was checked in to WordPress’s SVN repository which adds a “separator location” argument to the built-in wp_title() function. What that means, is that when WordPress v2.5 is released around March 10th of this year, users will be able to change the ordering of their HTML title tags without having to use a third-party plugin.

The developers decided not to change the default behavior of wp_title(), and instead added the additional argument to the function in order to prevent breaking existing themes that rely on the current behavior.

How to Make the Change

If you’re currently using Optimal Title and want to change your template back to using wp_title() after upgrading to WordPress v2.5 (and you should), here’s what you need to do…

Using the simplified example from the original Optimal Title article, you should currently have something like this in your theme’s header.php file:

<title><?php optimal_title(); ?> <?php bloginfo('name'); ?></title>

Just replace the function call optimal_title() with a call to wp_title('&raquo;',TRUE,'right'), and you’ll end up with something like this:

<title><?php wp_title('&raquo;',TRUE,'right'); ?> <?php bloginfo('name'); ?></title>

That’s it!

Parameters

The wp_title codex page won’t be updated until the next release, however, here is how wp_title() will work after WordPress v2.5 is out:

<?php wp_title('separator', display, 'seplocation'); ?>

  • 'separator' - string - The text to place between portions of the page title, such as the blog name and the category. Defaults to '&raquo;' (»).
  • display - boolean - Should the title be displayed (TRUE) or returned for use in PHP (FALSE). Defaults to TRUE.
  • 'seplocation' - string - The location of the separator in relation to the title. All values default to the standard left position, with the exception of 'right', which will place the separator after the title rather than before.

I’m Glad

Even though it took so long to get this done, I’m glad WordPress finally came around to the idea and added Optimal Title’s functionality to the core. Regardless of whether or not you were using Optimal Title before, I’d highly recommend that all users make this simple change to their templates in order to take advantage of the many benefits that a proper title tag has to offer.

13 Comments

  1. Andrew
    Posted March 4th, 2008 at 4:16pm | Permalink

    Thanks for this heads up.

    P.S. There’s a typo in the webhost link in your footer.

  2. Posted March 4th, 2008 at 4:26pm | Permalink

    “P.S. There’s a typo in the webhost link in your footer.”

    Fixed, thanks!

  3. Shawn
    Posted March 27th, 2008 at 11:40am | Permalink

    Hi Aaron,
    I found I had to be explicit with the arguments for wp_title() in 2.5 RC2
    e.g.
    wp_title(’»’,'TRUE’,'right’)
    The method you posted above generated a parsing error.
    HTH
    Shawn

  4. Posted March 28th, 2008 at 11:52am | Permalink

    I just downloaded the latest version of Wordpress - I think it’s 2.3.3. Should I install Optimal Title’s still? March 10th has passed and they are not at 2.5 yet - so I’m guessing they haven’t remedied this SEO title issue?

    Thanks!

  5. Posted March 28th, 2008 at 7:23pm | Permalink

    “I found I had to be explicit with the arguments for wp_title() in 2.5 RC2″

    Thanks for the heads up, I’ll update the entry to reflect that change…

    “I just downloaded the latest version of Wordpress - I think it’s 2.3.3. Should I install Optimal Title’s still?”

    Up until v2.5 is released, yes Optimal Title is still necessary. If you try one of the release candidates for v2.5 then the new changes have been included and you don’t need the plugin. They are currently on the second release candidate and I expect a formal release for v2.5 won’t be too far behind.

  6. Posted April 7th, 2008 at 10:20am | Permalink

    Thanks for posting this. After fumbling around for about 30 minutes, I found this article and had an elegant solution in about 30 seconds. Thanks!

  7. tbronson
    Posted April 12th, 2008 at 2:29am | Permalink

    Thans for the clear documentation.

    In 2.5, I used wp_title(’|',TRUE,’right’) to replace optimal_title here:

    Unfortunately, on non-home pages, the pipe still appears in front of the page title, so I went back to using Optimal Title.

    I’m using 2.5 and triple-checked the change for typos.

  8. tbronson
    Posted April 12th, 2008 at 2:30am | Permalink

    the snippet is:
    if ( is_home() ) { bloginfo(’name’); wp_title(’|'); } else { optimal_title(’|'); bloginfo(’name’); }

  9. Posted April 14th, 2008 at 4:43pm | Permalink

    Hi,
    I’m about to upgrade to Wordpress 2.5, and while beginning to look around for new plugin versions and stuff, I found my way here. I just wanted to say thanks for your time and for that cool plugin.

  10. Posted April 23rd, 2008 at 9:08pm | Permalink

    I feel stupid, but I am not able to get my title to change.
    The title reads Rotheblog | (Title)
    I inserted this line of code in the correct place, and expected to see (Title) | Rotheblog

    What am I doing wrong? Is there a setting in the admin area I need to change too?

  11. Posted April 23rd, 2008 at 9:15pm | Permalink

    Nevermind, stupid error, ignore.

  12. Posted April 23rd, 2008 at 9:25pm | Permalink

    I thought it was a stupid mistake, but it wasn’t. I still couldn’t get this to work for me.
    Then I remembered where it was set in the admin, in the All In One SEO plugin. So, do you even need to set this code up in the theme if you are using this plugin?

  13. Posted April 25th, 2008 at 9:43pm | Permalink

    For both tbronson and Jeff, it might help for you to see what I actually use on this site now that I’m running 2.5.1:

    <title><?php wp_title('|',TRUE,'right'); bloginfo(’name’); if ( is_home() ) { ?> | <?php bloginfo('description'); } ?></title>

    I don’t know much about the All In One SEO plugin, since I’ve never used it. It may change the title for you dynamically so making the change in your theme won’t make any difference. I do know that some themes out there either include support for Optimal Title directly, or include code that does a similar thing in their header.php files, so you might have to poke around to see if the theme your using is doing something non-standard.

Post a Comment

Your email address is never published nor shared. Required fields are marked *

*
*