Support » Plugins » Meta title – how fetch wp_title if no custom title field exists?

  • I’ve searched high and pretty low, with no luck so far. I have a pretty good meta title code for header.php here. It fetches the custom field “customtitle” for single & page. It works fine, but I’d like to have the default wp_title fetched/displayed if no “customtitle” (custom field) is specified on the page or post. This would cover the bases if I forget or don’t want to use a custom field title. Here’s the code. Please tell me how to modify this to include the wp_title if no custom field exists for “customtitle”. Thanks a bunch!

    ‘<title><?php if(is_home()) {echo bloginfo(‘name’) ; echo (‘ – ‘); echo bloginfo(‘description’);} else if(is_category()) {echo single_cat_title(‘Category – ‘);} else if(is_archive()) {echo single_cat_title(‘Category – ‘);} else if(is_search()) { ?>Search results for: <?php echo wp_specialchars($s, 1);} else if(is_404()) { echo ‘ 404 error – page not found ‘;} else {echo get_post_meta($post->ID, customtitle, true);} ?></title>’

  • The topic ‘Meta title – how fetch wp_title if no custom title field exists?’ is closed to new replies.