SEO your title tag
Only 2 months ago Alex Denning of Nometech.com wrote a guest post on CatsWhoCode that was titled "10 tricks to make your WordPress theme stand out".
Apart from all 10 amazing tricks, hacks and tips that I'm sure we will highlight one by one later on, for now we would like to focus on #2 in the list, the title tag.
Titles of your Posts, Pages, Archives and all other content are among the very important aspects of SEO and Alex hits the nail on the head with this extensive code!
Go into your header.php file and delete whatever there is now between your title tags. Then place the code below in it and you're one step closer to getting found in the search engines!
<?php if ( is_home() ) { ?><? bloginfo('name'); ?> | <?php bloginfo('description'); ?><?php } ?>
<?php if ( is_search() ) { ?>Search Results for <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); echo $key; _e(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?><?php } ?>
<?php if ( is_404() ) { ?><? bloginfo('name'); ?> | 404 Nothing Found<?php } ?>
<?php if ( is_author() ) { ?><? bloginfo('name'); ?> | Author Archives<?php } ?>
<?php if ( is_single() ) { ?><?php wp_title(''); ?> | <?php $category = get_the_category(); echo $category[0]->cat_name; | <? bloginfo('name'); ?><?php } ?>
<?php if ( is_page() ) { ?><? bloginfo('name'); ?> | <?php $category = get_the_category(); echo $category[0]->cat_name; ?>|<?php wp_title(''); ?><?php } ?>
<?php if ( is_category() ) { ?><?php single_cat_title(); ?> | <?php $category = get_the_category(); echo $category[0]->category_description; ?> | <? bloginfo('name'); ?><?php } ?>
<?php if ( is_month() ) { ?><? bloginfo('name'); ?> | Archive | <?php the_time('F, Y'); ?><?php } ?>
<?php if ( is_day() ) { ?><? bloginfo('name'); ?> | Archive | <?php the_time('F j, Y'); ?><?php } ?>
<?php if (function_exists('is_tag')) { if ( is_tag() ) { ?><?php single_tag_title("", true); } } ?> | <? bloginfo('name'); ?>
Moreover at WP Recipes Jean offers a more simplified solution with his recipe How to: Make your title tag SEO friendly:
<title>
<?php if (is_home () ) {
bloginfo('name');
} elseif ( is_category() ) {
single_cat_title(); echo ' - ' ; bloginfo('name');
} elseif (is_single() ) {
single_post_title();
} elseif (is_page() ) {
bloginfo('name'); echo ': '; single_post_title();
} else {
wp_title('',true);
} ?>
</title>
This solution can of course also be adapted to your own wishes. You can for example make an array for the archives and everything singular:
if ( is_singular() || is_archive() ) { echo wp_title(' - ', true, 'right'); ' | '; bloginfo('name'); }
Whichever you choose make sure to change those standard title tags!
Popularity: 44% [?]





