Your Ad Here

Optimize Title Tags in WordPress Posts

Date: 24 Jan 2010 Comments: 0
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in D:\Hosting\3681091\html\blog\wp-content\plugins\digg-digg\dd.class.php on line 759

Warning: file_get_contents(http://feeds.delicious.com/v2/json/urlinfo/data?url=http%3A%2F%2Fwww.devtheweb.net%2Fblog%2F2010%2F01%2F24%2Foptimize-title-tags-in-wordpress-posts%2F) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in D:\Hosting\3681091\html\blog\wp-content\plugins\digg-digg\dd.class.php on line 759

While I was searching something in google I saw in the results link to my site:

It’s awful, there’s Blog Title, Blog Archive and part of the title. It doesn’t give any information to the user. So, he/she will never click on my blog link.

So, I decided to optimize my WordPress Blog’s title tag.

First, I searched for wordpress plugins, but the plugins I found wasn’t compatible with the latest WordPress version. So, I decided to fix it in the code. Here’s how I fixed it:

1. Open you Current Theme header.php file, your <title> tag should looks like:
<title><?php bloginfo(‘name’); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>

Change it with:

<title><?php wp_title(”, true); ?><?php bloginfo(‘name’); ?> <?php if ( is_single() ) { ?> | Blog Archive <?php } ?></title>

We are almost ready. Now if you upload and open single post page you’ll see in html code:
<title>  Your Post TitleBLOG_TITLE | Blog Archive</title>

we need to remove space after <title> tag and to add space between Your  Post Title and BLOG_TITLE.

2) Open wp-includes/general-template.php

go to the end of wp_title function and replace the following line:

$title = apply_filters(‘wp_title’, $title,
$sep, $seplocation));

with

$title = trim(apply_filters(‘wp_title’, $title, $sep, $seplocation)) . ‘ ‘;

And that’s really all. Now, WordPress Post title tags will be:
POST_TITLE | BLOG_TITLE | Blog Archive. Let’s hope only google to reindex my blog pages soon :)

Leave a Reply


Spam protection by WP Captcha-Free