SEO Friendly Dynamic <title> for WordPress

Using a good <title> tag is incredibly important for ranking high in the Search Engines. This code snippet will dynamically generate a dynamic <title> tag to improve your WordPress site’s SEO and should be placed in your WordPress site’s header.php replacing your existing <title>.

<title><?php if ( is_category() ) {
	echo 'Category Archive for &quot;'; single_cat_title(); echo '&quot; | '; bloginfo( 'name' );
} elseif ( is_tag() ) {
	echo 'Tag Archive for &quot;'; single_tag_title(); echo '&quot; | '; bloginfo( 'name' );
} elseif ( is_archive() ) {
	wp_title(''); echo ' Archive | '; bloginfo( 'name' );
} elseif ( is_search() ) {
	echo 'Search for &quot;'.wp_specialchars($s).'&quot; | '; bloginfo( 'name' );
} elseif ( is_home() || is_front_page() ) {
	bloginfo( 'name' ); echo ' | '; bloginfo( 'description' );
}  elseif ( is_404() ) {
	echo 'Error 404 Not Found | '; bloginfo( 'name' );
} elseif ( is_single() ) {
	wp_title('');
} else {
	echo wp_title( ' | ', false, right ); bloginfo( 'name' );
} ?></title>

For other ways to improve your WordPress theme, be sure to check out our other WordPress code snippets.

For other ways to use WordPress to gain rankings in the Search Engines, be sure to check out our other WordPress SEO articles.

Follow wpLifeGuard

« Back to Blog