Programming tip for Jerome’s Keywords and Optimal Title

Advertisement

As I know there’s a lot of WordPress bloggers out there using Optimal Title so that their blog title ends up with the story title before the blog title, because if the full title gets truncated by a search engine, the important story part is less likely to get the chop.

However, if you add into the mix Jerome’s Keywords (a plugin I heartily recommend to anyone), one problem you may soon notice is that if you don’t add a custom tag results page, the title for tag lookups like http://whatjapanthinks.com/tag/plugin ends up as merely the default blog name, which is rather poor from a search engine perspective.

So, looking at the source code for optimal_title.php in the plugins directory, I found how to insert an extra line or two that adds the tag lookup keywords if present. The code before modification looks like this:


if (!empty($category_name)) {
$title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
}

// If there's a month

Now, insert the following extra condition as highlighted in bold:


if (!empty($category_name)) {
$title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
}

// The following four lines have been inserted
if ( $title == "" && get_the_search_keytag() != "" )
{
$title = get_the_search_keytag();
}

// If there's a month

Now if you click on a tag at the bottom of any story, you will see the title of the tag lookup page now starts with the tag name. Hopefully this change does not break any other code. This has not been fully tested in any sense whatsoever, so please do the modifications at your own risk!

Read more on: ,,,,

Custom Search

Leave a Comment