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.

Please bookmark or vote!:
  • Digg
  • del.icio.us
  • Reddit
  • Mixx
  • Propeller
  • Sphinn
  • StumbleUpon
  • TwitThis
If you found this article useful, bookmark it at Del.icio.us for future reference
Subscribe now with RSS, daily emails or weekly emails to receive more tips, new media news and a FREE ebook!

5 Comments so far

  1. John Wesley February 23rd, 2007 2:25 pm

    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. J.D. February 23rd, 2007 5:18 pm

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

  3. Chris Garrett February 23rd, 2007 5:27 pm

    Glad it’s useful guys

  4. Marios Alexandrou February 25th, 2007 11:15 pm

    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.

  5. James February 27th, 2007 10:30 pm

    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

Free Gifts

Receive more free blogging, writing and marketing tips to your email inbox or feed reader, plus a free eBook download.

Feed Count Subscribe now with RSS or
get articles by Email

Subscribing is free, and your email will never be shared

About Chris Garrett

Chris Garrett is a blogging and internet marketing consultant. This blog is here to help you make the most out of the web.

Follow me on twitter Read more about Chris and this blog.

View Chris Garrett's profile on LinkedIn FaceBook

Search this site

  • Popular Articles

  • Recommends

  • Categories

      Archives

      Hosting By