0
<head>
<title>
    <?php wp_title(''); ?>
</title>
</head>

This displays the page title in the title correctly everywhere except on the front page where it displays "Home | Motto...". How can I have the front page display the page title like it does everywhere else on the site?

  • Can you provide a little more context? Are you developing a theme? Are you using any plugins, especially SEO plugins? Are different templates being used? Are you calling wp_title() exactly the same way? This may help too: wordpress.stackexchange.com/questions/43619/… – Nathan Johnson Feb 13 '17 at 18:43
1

I'm not very sure how is your title on other pages, but here is how you can modify your title:

<?php wp_title( '|', true, 'right' ); ?>

This will show your Blog's name right to your page's title, which will have seo benefits. The | separator will be used here.

If you want to customize your title further, you can use a situational if(), as the following:

<title> <?php if ( is_home() ) { //Your custom title here } else { wp_title(''); } ?> </title>

For custom title, you can use the following outputs:

bloginfo('name') = Displays the “Site Title” set in Settings > General

bloginfo('description') = Displays the “Tagline” set in Settings > General

Or you can simply type your desired title in text format.

0

why not replacing wp_title with add_theme_support function with 'title-tag' parameter. this method is more convenient then the other. maybe it'll help you.

function wpse_1012_setup() {

 add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'wpse_1012_setup' );

remove the title tag from head section and if wp_head is present in header.php then the page title should work correctly.

0

You can simply place a if around your wp_title function like this :

<head>
<title>
    <?php 
    if (is_home()){
        echo 'Your home title';
    } else {
        wp_title();
    }
    ?>
</title>
</head>

Or the right way to do it would be to apply a filter on the title to alter it by placing this code in function.php.

add_filter( 'pre_get_document_title', 'generate_custom_title', 900 );
function generate_custom_title($title) {
     if (is_home()) {
        $title = "Your title here";
     } 
     return $title;
}

if you do use Yoast plugin for SEO, you can also add this line to apply title to the Yoast meta titles

 add_filter( 'wpseo_title', 'generate_custom_title', 900);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.