This article has been retired and will no longer be updated. Caveat emptor!

— Originally Published on September 08, 2004 —

WP Plugin: Optimal Title

This plugin is now deprecated…see Optimal Title Functionality Now in WordPress Core.

IMPORTANT!!!

Due to recent XSS security issues fixed in WordPress 2.1.3, the code for Optimal Title also had to change in order to fix the vulnerabilities. It is recommended that ALL users of this plugin upgrade to version 3.0. Due to changes in how Optimal Title works, that should be the last upgrade you will ever need For more details, see the update details section below…


Optimal Title is a WordPress plugin that mirrors the function of wp_title() exactly, but moves the position of the 'separator' to after the title rather than before. This allows you to have your blog name tacked on to the end of the page title instead of having it appear first.

Having your page information appear before your blog name in the title is advantageous because it provides more meaningful search engine results and browser bookmark names The text that appears between your <title> tags is used to generate both of these things, and will often be truncated when viewed. Because of this, it is more effective to have words directly relating to the content of your page appear before common markers. Not only will the titles be more meaningful, but the they will also be more scannable when being viewed in a list For more information on this concept, see Dr. Jakob Nielsen’s article Microcontent: How to Write Headlines, Page Titles, and Subject Lines.

Installation

  1. Download Optimal Title v3.0 and unzip the archive.
  2. Upload optimal-title.php into your wp-content/plugins/ directory.
  3. Activate the plugin on your WP Admin » Plugin Management page by clicking the corresponding “Activate” link under the Action column.
  4. Follow the usage guidelines shown below…

Usage

In your header.php file, replace the function call wp_title() with a call to optimal_title(). You’ll also want to position your blog name after your usage of Optimal Title in order for this to work as intended. You should end up with a line that looks something like this:

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

For a more complicated version that checks to make sure the plugin is installed and also includes support for a tagline on the home page, this is actual code I use on this site:

<title><?php if ( function_exists('optimal_title') ) { optimal_title('|'); bloginfo('name'); } else { bloginfo('name'); wp_title('|'); } ?><?php if ( is_home() ) { ?> | <?php bloginfo('description'); } ?></title>

Parameters

Optimal Title uses the same syntax as wp_title, from the default WP installation, and thus functions in the exact same way…

<?php optimal_title('separator', display); ?>

Version History

v3.0 Update Details

Upon the suggestion of Lee Kelleher, the way in which Optimal Title works was adapted in order to be more efficient, future-proof, and secure. The plugin no longer generates the title text itself, but lets the built-in wp_title() function handle the generation, then rearranges things afterward. Because of this change, Optimal Title will have the exact same security implications as the default installation of WordPress itself and should never need to be upgraded again…in other words, if your WordPress installation is up to date, you’ll never have to worry about the security of using Optimal Title. That also means that the plugin should work for ANY version of WordPress, past, present, and future.

This article has been retired and will no longer be updated. Caveat emptor!

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.