Simple better titles for your WordPress website

Go to source

First, make sure that your theme uses wp_title(). So go to your theme’s header.php and check so that it has the following set:

<title><?php wp_title(''); ?></title>

You’ll need the ” there as well to remove some default arrows that WP adds.

Next, add this to your functions.php:

/*  Site title
/* ------------------------------------ */
function alx_wp_title( $title ) {
	// Do not filter for RSS feed / if SEO plugin installed
	if ( is_feed() || class_exists('All_in_One_SEO_Pack') || class_exists('HeadSpace_Plugin') || class_exists('Platinum_SEO_Pack') || class_exists('wpSEO') || defined('WPSEO_VERSION') )
		return $title;
	if ( is_front_page() ) {
		$title = bloginfo('name'); echo ' - '; bloginfo('description');
	}
	if ( !is_front_page() ) {
		$title.= ''.' - '.''.get_bloginfo('name');
	}
	return $title;
}
add_filter( 'wp_title', 'alx_wp_title' );

This will results in the following simple but good site titles:

  • On front page: Site Title – Site Description
  • On other pages: Default WP Page Title – Site Title

If you want to change the separator, just replace the two instances of “-” in the code with for example “|”.

Of course there are way more advanced methods and SEO plugins out there, but this is if you just want to keep it neat and simple.