Redifine wordpress title tag with a custom field

February 1, 2009 · Print This Article

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.


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.