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.
Posted on February 23rd, 2007 by Chris Garrett in Blogging, Development











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.
Awesome. Thanks for this. I’ve been meaning to do this for a while, but never knew how.
Glad it’s useful guys
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.
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