Sign up right now for email updates and get two free ebooks:

WordPress Hacking for Better Blog Titles

Here is a quick tip for any WordPress users frustrated at the crappy default page titles you get with most templates. I got asked yesterday how I changed mine and if I used a plugin. No, it’s way easier than that.

Go into your WordPress admin and navigate to Presentation then Theme Editor. You need to edit your Header template. Find the Title tags. Replace with the following:


<title><?
php

// if is the homepage, display
// just the blog name
// otherwise use the post title
if(is_home())
{
echo bloginfo('name');
}
else
{
wp_title('');
echo ' : ';
echo bloginfo('name');
}

?></title>

What this code will do is display your blog name (set in options) for the homepage, otherwise your post title (or archives, whatever) followed by your blog name.

If you want to display something other than your blog name replace “bloginfo('name')” with the text of your choice surrounded by quotes, eg.

echo "Chris is fantastic";

That’s all there is to it really. Let me know if I haven’t made this clear.

Sign up right now for email updates and get these
two free ebooks

"Creating Killer
Flagship Content"

"Authority Alliances"

Just enter your primary email address in the form below and hit the button!

Before commenting, please read my Comments Policy - thanks!

Comments

  1. Nice little hack, I’ve actually wanted to do this for a while, but hadn’t been able to get the php code right. Thanks a lot.

  2. Nice little hack, I’ve actually wanted to do this for a while, but hadn’t been able to get the php code right. Thanks a lot.

  3. Awesome. Thanks for this. I’ve been meaning to do this for a while, but never knew how.

  4. Awesome. Thanks for this. I’ve been meaning to do this for a while, but never knew how.

  5. Glad it’s useful guys

  6. Glad it’s useful guys

  7. I got one step further and use the same technique to give me proper meta description and meta keywords depending on the page type i.e. home, post, category.

  8. I got one step further and use the same technique to give me proper meta description and meta keywords depending on the page type i.e. home, post, category.

  9. This is going to sound like a real “plug”, but a week or 2 ago I wrote a similar post, with a couple more options (like your search results page and category pages). You can check them here (if the link works):

    Great WordPress Titles

  10. This is going to sound like a real “plug”, but a week or 2 ago I wrote a similar post, with a couple more options (like your search results page and category pages). You can check them here (if the link works):

    Great WordPress Titles