How to Optimize WordPress Titles for SEO

By default, your WordPress will come with the following code in your header.php file.

<?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive < ?php } ?> <?php wp_title(); ?>
*located between the title tags.

This code generates a title that looks something like :

“Bo’s Blog >> How to Be Like Bo”

First, it displays your blog title, followed by the title of the post. If you do nothing, you will end up with search engine listings like this one. This is a Google listing of my dear friend, Joel’s site. I’m using his site an example with his permission.

Do you see the listing have same titles? This is not the way you want. Also note the dates appearing as your first keyword. Joel forgot to setup permalink feature, so his url contains letters and numbers by default.

In this post, I will show you how to have a search engine listing that has your post topic as your main title followed by the blog title(optional). Take a look at my listings from Google and MSN. For the first screenshot, I forgot to put a dash between the title and the blog title. Second screenshot is what you might want to accomplish. Please note I removed the date info to make it look better. And..I don’t use meta keywords and descriptions. I let the spiders decide what the page is about.

So let’s begin.

Open your header.php file from your template folder. Then find :

< ?php bloginfo('name'); ?> < ?php if ( is_single() ) { ?> » Blog Archive < ?php } ?> < ?php wp_title(); ?>
*between the title tags

You will going to replace this with the following code.

< ?php wp_title(''); ?>< ?php if(is_single()) {;?> - < ?php } ?> Put Your Blog Title here
*remove the space before “?php” tag

Let’s take a look at one code at a time.

< ?php wp_title(''); ?>

This function will display the title of your post. It is important that you put two single quotes inside the brackets.

< ?php if(is_single()) {;?> - < ?php } ?>

This functions tells WordPress to show the dash only when the page is a post page. If it’s your home page, it will not display.

Put Your Blog Title Here

This is where you put your blog title. Make it short and keyword rich. This ignores the blog title setup from your control panel. We can use a function here as well, but I like to do some manual coding for my site. :)

There are other ways to implement this code, but I will leave it up to you to experiment. If you need help, please let me know.

WordPress 2.0 Now Available Setting goals…

8 comments so far

  1. Affiliate Moneymaking (Pat)

    The code I pasted in my last comment did not show up. So I will just tell you what I did.

    I replaced “is_single” by “is_home” and then put in “{ } else ” after the “is_home”.

    This way, every page except the home page will get the “-”.

  2. Affiliate Moneymaking (Pat)

    This is a great idea! However, it did not come out quite right on the category pages. I changed your code a little as follows:

    - Put Your Blog Title Here

    This seemed to work for everything. Thanks for the idea!

  3. Bo Bang

    This is why I need your inputs :) I didn’t know the plugin existed.

    We now have more than 3 ways to fix your titles, choose one and fix it now! :)

  4. Abdul

    Or you can just use optimal title plugin and let it do evetything for you?

  5. Rodney Boettger

    There is a plugin called Optimal Title that does this same thing for those wanting to accomplish this via a plugin.

    You can find it at

    http://elasticdog.com/2004/09/optimal-title/

  6. Tim Linden

    Thanks. I did this on my previous template, but you posting about it reminded me I didn’t on my new template! I’m writing this down on my blog checklist ;-)

  7. Rod H

    Oooops the code snippet didn’t work above. Here it is.

  8. Rod H

    Just a little extra tip. If you add is_archive() and is_page() in the IF statement it will catch all your pages, category, and date based archives as well. Sample code below.

Leave a Reply





XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

SUBSCRIBE FOR UPDATES

RSS

Or, receive updates via email.