Get A Better WordPress Title In 30 Seconds!

Over the years there have been many attempts at improving the way WordPress displays your blog's page title. There are several plugins that let you modify the way your title is displayed and some that even let you specify a title for your posts.

I've tried several of these solutions and, honestly they have all been lacking in one way or another. I'm not going to run down a laundry list of what I don't like about each one, but no doubt many others have felt the same way about this situation as I have. So, I'm talking to you here.

I believe I have a better way. And it doesn't involve messy plugins with all sorts of other unnecessary features or typing in yet another field in your write post page.

This code will help you a lot with seo on your blog because it will put the important part of your title first and place your blogs name at the end of the title. Best of all, it's a completely fire and forget solution.

Here's the code you need.

[php]
<br /> < ?php<br /> if (is_home()) {<br /> ?><br /> WordPress Themes, Plugins, Hints and Tips | Blog Strokes<br /> < ?php<br /> } else {<br /> if(function_exists('UTW_ShowCurrentTagSet')) {<br /> if (is_tag()) {<br /> UTW_ShowCurrentTagSet('tagsettextonly');<br /> echo ' | ';<br /> bloginfo('name');<br /> } else {<br /> wp_title(' ');<br /> if(wp_title(' ', false)) { echo ' | '; }<br /> bloginfo('name');<br /> }<br /> }<br /> }<br /> ?><br />
[/php]

Now all you have to do is open up your header.php for your theme and locate the <title> ... </title> section. Delete everything between those tags and copy/paste this code in it's place(be sure to click on the "Plaing Text" link before you copy).

This code has support for the Ultimate Tag Warrior Plugin which I use on all of my blogs, so it will also display your current tag set when you are on a tag page, but if you do not have UTW installed, it will skip that part and not cause any errors.

Let me know if you try this out. Let me know if you have any problems with it, and I'll be glad to help you out.

Trackback URL for this post:

http://danemorgan.com/trackback/8
None
Login or register to tag items
 
Posted In
Tagged With
Like this?
Bookmark & Share:
StumbleUpon Submit to Mixx Save to Google Bookmarks Save to del.icio.us
Click, Copy and Link:
<a href="http://danemorgan.com/blog/wordpress/get-better-wordpress-title-30-seconds">Get A Better WordPress Title In 30 Seconds!</a>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Tax deduction tips... A tax

Tax deduction tips...

A tax is a financial charge or other levy imposed on an individual or a legal entity by a state or a functional equivalent of a state...

The Tax system explained (not verified) | Wed, 02/06/2008 - 18:45

To get the individual posts

To get the individual posts title tags in I did a slight mod by adding . This seems to load the main page title well and the individual post titles well.

Pass Your Drug Test

Ben (not verified) | Thu, 01/31/2008 - 11:53

Thanks for this solution.

Thanks for this solution. The default WP title definitely needs adjusting.

teia (not verified) | Wed, 10/03/2007 - 00:09

Yeah, Vlad you can do that

Yeah, Vlad you can do that easily. Just remove the bloginfo('name'): from everywhere but the main part for the home page.

Actually, in my code I hard wired the home page title with "WordPress Themes, Plugins, Hints and Tips | Blog Strokes". So to do what you want delete the two lines

if(wp_title(' ', false)) { echo ' | '; }
and
bloginfo('name');

both times they appear. This will leave you home page with whatever you type in the first section, and the rest of your pages with just the title for the page.

And yes, I suddenly received a serious traffic spike out of no where. When I went looking for where it came from it came from Stumble, and it all came to this post, so I figured you had stumbled me.

Dane Morgan (not verified) | Fri, 07/20/2007 - 17:49

Thanks Dane. But I there was

Thanks Dane. But I there was some miscommunication on my part... I am thinking to use "bloginfo" only on the home page but for single posts I want to try only post's title.
I also answered your question on my blog about Stumble... Yes it was me. I hope you getting some visitors.

I also like the idea to play withe code instead of plugins. I just wish I can do what you do... Oh well, that's why this whole blogging thing is so cool- you can always learn from other bloggers.

Vlad (not verified) | Fri, 07/20/2007 - 08:14

Hi Vlad, The blog name is

Hi Vlad,

The blog name is inserted with this code
[php]
bloginfo('name');
[/php]

So to have it not show up on tag pages just remove it from the UTW section, and to have it not show up on other types of pages remove it from the else { } section.

If you wanted to add it back in to certain sections you could add another if() statement for those sections like
[php]
if (is_page()) {
wp_title(' ');
if(wp_title(' ', false)) { echo ' | '; }
bloginfo('name');
}
[/php]
The UTW code is there to output the tag set as the title on your UTW tag pages.

Dane Morgan (not verified) | Fri, 07/20/2007 - 06:52

How come I am in pink? -

How come I am in pink?

- Fixed ;) I had turned it of for some troubleshooting. good catch, thanks. Dane -

Vlad (not verified) | Fri, 07/20/2007 - 03:46

Dane, I am guessing you are

Dane,

I am guessing you are in favor of adding the name of the blog to every post. However I would rather use code like this over the plugin.

What would I need to modify if I were to us this code but decided to not "brand" my every single post?

Also, what is UTW doint in the title?

Vlad (not verified) | Fri, 07/20/2007 - 03:22

Hey! Nice blog...I have had

Hey!

Nice blog...I have had good luck using the Utopia 1 plugin for my WP titles. I will give your code a go, Dane, and see if it improves my mood...

Peace,

Charlie~

:D

Charlie43 (not verified) | Wed, 07/04/2007 - 20:13

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Restrict text by wrapping in [restrict:roles=<comma separated roles>] and [/restrict]
  • Links to specified hosts will have a rel="nofollow" added to them.

  • Highlight terms in this textarea.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Use <fn>...</fn> to insert automatically numbered footnotes.
  • You may link to webpages through the weblinks registry

More information about formatting options

CAPTCHA
Please fill out this captcha to demonstrate your humanity.
4 + 10 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.