WordPress SEO: Better Titles

WordPress SEO: Better Titles

The content of the HTML tag is used to:

  • Create a title in the browser toolbar
  • Provide a title for the page when it is bookmarked
  • Display a title for the page in search-engine results

It make sense, therefore, to take some time to craft a good title in your WordPress site. In the vast majority of WordPress themes, the title is generated in the theme’s header.php template file. So you need to start by editing this file.

Some themes simply use something like:

<?<span class=”hiddenSpellError” pre=””>php</span> wp_title();?>

But that’s not nearly enough to generate a good title. What you want is code that generates informative, page-specific, titles. So try something like:

<title><?php global $page, $paged;

if ( $paged >= 2 || $page >= 2 ) $we_are_on = sprintf( __( ‘ (Page %s) ‘ ), max( $paged, $page ) );

else $we_are_on = ”;

if( is_home () ) : printf(__( ‘%1$s%2$s on %3$s’), wp_title(”, false), $we_are_on, get_bloginfo(‘name’) );

elseif( is_search() ) :

if( trim( get_search_query() ) == ” ) printf(__(‘No search query entered on %1$s’), get_bloginfo(‘name’) );

else printf( __( ‘Search Results for \’%1$s\’ on %2$s%3$s’ ), trim(get_search_query() ), get_bloginfo(‘name’), $we_are_on );

elseif ( is_category() || is_author() ) : printf(__( ‘%1$s%2$s on %3$s’ ), wp_title(”, false), $we_are_on, get_bloginfo(‘name’) );

elseif( is_tag() ) : printf( __(‘Entries tagged with \’%1$s\’%2$s on %3$s’) , wp_title(”, false), $we_are_on, get_bloginfo(‘name’) );

elseif( is_archive() ) :

printf( __(‘Archives for %1$s%2$s on %3$s’), wp_title(”, false), $we_are_on, get_bloginfo(‘name’) );

elseif( is_404() ) : printf(__( ‘Page not found on %1$s’ ), get_bloginfo(‘name’) );

else : printf( __(‘%1$s%2$s’), wp_title(‘:’,true, ‘right’), get_bloginfo(‘name’) );

endif;

?>

</title>

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: