• May.
  • 17.
  • 2008

Beefy SEO Title Tags for WordPress Header.php

WordPress title tags in your theme’s header.php may not be the SEO ideal.
Try this instead:

<title><?php

	// Page or Single Post
	if ( is_page() or is_single() ) {
		the_title();

	// Category Archive
	} elseif ( is_category() ) {
		printf( __('Archive for &lsquo;%s&rsquo;'), single_cat_title('', false) );

	// Tag Archive
	} elseif ( function_exists('is_tag') and function_exists('single_tag_title') and is_tag() ) {
		printf( __('Tag Archive for &lsquo;%s&rsquo;'), single_tag_title('', false) );

	// General Archive
	} elseif ( is_archive() ) {
		printf( __('%s Archive'), wp_title('', false) );

	// Search Results
	} elseif ( is_search() ) {
		printf( __('Search Results for &lsquo;%s&rsquo;'), get_query_var('s') );
	}

	// Insert separator for the titles above
	if ( !is_home() and !is_404() ) {
		_e(' at ');
	}

	// Finally the blog name
	bloginfo('name');

	?></title>
This entry was posted in Technical Blog, WordPress and tagged , . Bookmark the permalink.

One Response to Beefy SEO Title Tags for WordPress Header.php

  1. San Fran Webdesign wrote:

    As a fellow webdesigner , I’m extremely glad to see that someone thought to post this topic.

    All too many people just don’t understand what all is needed in this industry, and I think also we are many times not appreciated enough
    or taken for granted. Never the less I’m very glad to see that you feel the same way I do , thanks so much for your blog!