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('»',TRUE,'right'), and you’ll end up with something like this:
<title><?php wp_title('»',TRUE,'right'); ?> <?php bloginfo('name'); ?></title>
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
- display – boolean – Should the title be displayed (
TRUE) or returned for use in PHP (
FALSE). Defaults to
- '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.
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.