Optimizing WordPress Title

This might be known to most WordPress developer that sensitive with search engine optimization for WordPress title. But for newbies, this will be useful and should always be taken into account when developing a WordPress theme. Without using any plugin, this hack is very essential.

By default a WordPress theme will be built with standard title code such as:

[sourcecode language=’php’]<?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?>[/sourcecode]


This is likely not the best way to make the title visibly friendly to search engine as each pages and post will display the same code for every title. Ideally, they must be custom to each and individual pages or post accordingly how they should be displayed. It is recommended to use such as:

[sourcecode language=’php’]<?php if (is_home () ) { bloginfo(‘name’); } elseif ( is_category() ) { single_cat_title(); echo ‘ - ‘ ; bloginfo(‘name’); } elseif (is_single() ) { single_post_title();} elseif (is_page() ) { single_post_title();} else { wp_title(‘’,true); } ?>[/sourcecode]


This code will actually display a custom title for each different type of page on your blog automatically. This is the basic of manual coding of optimizing title for WordPress.

If you’re really considering search engine optimization as high importance in WordPress development, using plugins might be very handy in this situation. Such are as:

All in One SEO Pack and WordPress SEO.