
Some time ago, I shown you how to make your title tag SEO friendly. Even if it is already cool, this function can still be enhanced by using a custom field. Read on if you’re interested.

Some time ago, I shown you how to make your title tag SEO friendly. Even if it is already cool, this function can still be enhanced by using a custom field. Read on if you’re interested.
Open your header.php file for edition. find the <title> tag, and replace it by the following code:
<title>
<?php if (is_home () ) {
bloginfo('name');
} elseif ( is_category() ) {
single_cat_title(); echo ' - ' ; bloginfo('name');
} elseif (is_single() ) {
$customField = get_post_custom_values("title");
if (isset($customField[0])) {
echo $customField[0];
} else {
single_post_title();
}
} elseif (is_page() ) {
bloginfo('name'); echo ': '; single_post_title();
} else {
wp_title('',true);
} ?>
</title>
Then, if you want to define a custom title tag, simply create a custom field named title, and give your title as a value.
14 Responses
Hi, this is exactly what I’ve been looking for — thanks very much! Just one question — as of now, on a single post, only the title of the post is generated and displayed. Is there any way for me to also display the title of my blog after the title of the post? Thanks!
Never mind, I figured out how to do it myself. Thanks again and keep up the great work.
I usually just code my title tag so this is unnecessary, but it’s always good to know. Keeps expanding my knowledge of Wordpress
Ups, it looks like I cannot paste the code
Nevertheless, i just copied / paste the code you provided.
very cool , all of your Tutorials just awesome
A simpler option is to use the All in One SEO Pack plugin which lets you customise the title and description meta tag for each post. http://su.pr/1K5SCu
This trick was very useful for me. Thanks!!
Trackbacks: