DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

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:


<?php if (is_home () ) {
} 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 {
} elseif (is_page() ) {
    bloginfo('name'); echo ': '; single_post_title();
} else {
} ?>

Then, if you want to define a custom title tag, simply create a custom field named title, and give your title as a value.


Leave a Comment

Your email address will not be published. Required fields are marked *