Home Daily Marketing Tips About Me Work With Me

Marketing & Design Blog

Internet Marketing, SEO, Blogging, Social Media, Lead Generation and Analytics

Optimizing Word Press Title Tags

, ,

Many users of Word Press have found issues with their title tags that render their links poorly in the search engines.

These are the main problems that users wish to fix about the title tags are:

.) Place post title before the blog title
.) Remove the dash (or ») when there is not post title.
.) Users wish to remove the “»” altogether from the title tags.

Let’s start with the first issue of changing the order of display in the Word Press title tags. For SEO purposes, you would be better off having the title of your actual post appear in the TITLE tag first, like: “Post Title » Blog Title” rather than the other way around.

To make this change, go into the theme editor of your Word Press admin and click into the heder.php file. In the top of the file look for the section that starts with “<title>”.

First, remove everything from between the <title> tag to the </title>. This should result in your TITLE tags looking like this:

<title>
</title>

Next, add the following lines of code into their own lines between the TITLE tags so that your TITLE section looks like this:

<title>
<?php wp_title(); ?>
<?php bloginfo('name'); ?>
</title>

Now if you go back and look at your site’s pages you will see that we have reversed the order of the TITLE tag, placing the post title in front of the blog’s title. However, this is still not perfect, as you will see that the the “»” appears in front of the post title on your post pages, rather than in between the post title and the blog title as it is intended.

To fix this issue, go back to the theme editor for the header.php file and again find the TITLE section of the file near the top.

We are going to again add some code to that section of the header.php file. Add the following code to TITLE section so that your TITLE section looks like this:

<title>
<?php wp_title(); ?>
<?php if(wp_title('', false)) { echo ' &raquo; '; } ?>
<?php bloginfo('name'); ?>
</title>

You will find that this almost solves the problem, by placing the “»” in between the post title and the blog title where it belongs; however this still leaves another instance of the “»” at the very front of the TITLE tags on the blog pages.

To fix this we have to make another small change to the TITLE section of the header.php file from the theme editor of the admin panel.

The title tag we’ve been editing this far is actually abbreviated PHP code. There are some definable variables that are being allowed to fall back to their default states as defined by the main Word Press code. Because we haven’t indicated for the script to act otherwise, the script is falling back to its default behavior.

To fix this issue, we are now going to change the first line of the TITLE section in the header.php file to the following:

<?php wp_title(' ' ; ?>

Your entire TITLE section of the header.php file should now look like this:

<title>
<?php wp_title(' '); ?>
<?php if(wp_title('', false)) { echo ' &raquo; '; } ?>
<?php bloginfo('name'); ?>
</title>

This will now have your TITLE tags acting the way you want them to, with the post title being listed first and the blog title listed second. This also removes the separation from the title tags, when there is no post title for pages like the home page.

The only thing left is to change the separator from the “»” to another symbol.

To do this, you have to change the separator in the new TITLE section of your header.php page.

In your new TITLE section, you will see the following (I have bolded the part you are looking for):

<title>
<?php wp_title(' '); ?>
<?php if(wp_title('', false)) { echo ' &raquo; '; } ?>
<?php bloginfo('name'); ?>
</title>

You need to change the “&raquo;” to any other character that you wish. You may use a character entity chart to select a different separator, or you can go with a simple pipe (|) character the choice is up to you.

On my blog, I have chosen to use a simple pipe delimiter format like this:

<title>
<?php wp_title(' '); ?>
<?php if(wp_title('', false)) { echo ' | '; } ?>
<?php bloginfo('name'); ?>
</title>

Please let me know if there are any other issue that you find with the TITLE tags in Word Press, and I will see if I can help you solve them.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

12 Comments »

  1. Zach, great article! I have a WordPress Title related question…how do you include the Category name in the Title? The closest I’ve come to finding out is this WordPress support link ( http://wordpress.org/support/topic/33392 ). When I add the_category (etc.)I get the same extra info. in the Title and the person describes in the support forum.

    Thanks,
    Brendan

    Comment by Brendan — September 23, 2006 @ 8:15 pm

  2. Brendan,

    Unfortunately there is no perfect way to call the category to the title of your Word Press blog for all situations. There are several ways that the info can be called, but they may not be exactly what you are looking for.

    To show the category for every page in your blog (including the home page) you can try this:

    <?php $categories = get_the_category();
    echo $categories[0]->cat_name; ?>

    The good thing about this solution, is that it will show the category name for all individual posts, as well as all category pages. The bad thing about this solution is that it will also show the last category posted to on the home page.

    If you wish to only show the category name on actual category pages use this:

    <?php $categories = get_the_category();
     if ($cat==0) echo ""; elseif ($cat!==0)
    echo $categories[0]->cat_name; ?>

    The good thing about this solution is that it will not show anything in title for your home page. The bad part is that it will also not show the category name on each individual post.

    Aside from these two options, there really is no easy way to get the best of both worlds. I suppose it would be possible to query the database for the current, or associated category, and then replace the category ID with the category name. However, I do not want to post such a hack here – the follow up and support for me would be too much.

    If someone else reading this post would like to give it a try that would be great. I would be happy to post your outcome with a link to your site.

    Hope that helps!

    Comment by zacheos — September 24, 2006 @ 12:06 pm

  3. Thanks Zach! The first solution does what I was looking for except for the homepage issue. I want to put the categories in the title because, as I understand it, the title tag is important for SEO and my category names are good “keywords” to use. Now I’m wondering if having changing title tags for the homepage would be a bad thing in Google’s eyes? (I do think it looks bad for visitors to the homepage to see a stray category name in the title of their browser.)

    Brendan

    Comment by Brendan — September 24, 2006 @ 4:03 pm

  4. [...] Works like a charm. Thanks to Zach. Posted by Craig Filed in Web Tags: seo, wordpress [...]

    Pingback by Craig Childs — November 14, 2007 @ 7:17 pm

  5. Hi.
    Good design, who make it?

    Comment by naisioxerloro — November 28, 2007 @ 8:34 am

  6. small-for-gestational-age infant

    Comment by SheeroChorO — December 24, 2007 @ 3:14 am

  7. [...] more information on optimizing other blogging software, please see Optimizing Blogger Title Tags, Optimizing Word Press Title Tags and Optimizing Blogware Title Tags. Bookmark It Hide [...]

    Pingback by zacheos — May 17, 2008 @ 12:31 pm

  8. [...] to a very large response to my article about optimizing Word Press title tags, I figured I would write a few more articles describing how to optimize the title tags of other [...]

    Pingback by zacheos — May 17, 2008 @ 12:32 pm

  9. Thanks!,

    Comment by Mapgkumq — December 13, 2008 @ 9:11 am

  10. Hi!

    I’ve found your post to be very useful, though the information is not rather new.
    I’m your permanent reader now!

    p.s. BTW, what happened to your site template? Or is it just my browser? :)

    http://www.squidoo.com/Samsung-LN46A650-HDTV

    Comment by samsung LN46A650 — December 15, 2008 @ 10:50 pm

  11. Was just working on the site… Is the site looking okay now? Let me know if I am missing something here!

    Comment by zacheos — December 16, 2008 @ 9:53 am

  12. Hi

    As a fresh http://www.zachgraeve.com user i only want to say hi to everyone else who uses this site :-)

    Comment by Expimmiff — December 19, 2008 @ 1:37 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

logo design brand development

We have simplified the typical logo ordering process, put you in direct contact with the artist, made getting additional branding products and websites easy, and rounded it all off with high quality printing services at fantastic rates... Learn more

website design development

We have made getting a completely dynamic website built on the WordPress content management system with a theme of your choice easy. We integrate your logo into the site design and offer great add-ons at amazing prices - giving you a range of choices on design and layout... Learn more

search engine optimization

We have expert SEO consultants ready to tackle any aspect of your search engine marketing and optimization needs. We take pride in the ability to custom build an Internet marketing campaign that is perfectly suited to your needs.... Read more


© Copyright 2003-2010 Zach Graeve and Expert Online Services, LLC. All Rights Reserved.
 Subscribe, RSS, Comments RSS, XML Sitemap, Privacy Policy