0

I try every solution what I find on the net, but none of them work. I using generatepress.

My latest trying that, but not working...:

if ( is_front_page() && is_home() ) {
    remove_theme_support( 'title-tag' );
    echo '<title>' . get_bloginfo( 'name' ) . ' | mydomain.com</title>';
    }

Very frustrating, but it does not matter what i writing to between the <title> tags, I can even leave it empty so: <title></title>, in every case the output will be this:

   My Site Title | Tagline

I cannot use plugin for this, because I launch a multisite, and example if I modify my SEO plugin defaults settings in that core, the titles not will be dinamic on the home pages, so example my user create a page with this title: Original Site Title, I can solve it, that will be the home page title, if I get the bloginfo( 'name' ) in the All In One SEO Pack's core, but if my user change him site's title to Changed Site Title, the <title> tag (what generating the plugin) will using later on the first title.

  • hmmm maybe try it with OR instead of AND: if ( is_front_page() || is_home() )... as they do mean different things, they are not always the same page - depending on your setup. – majick Mar 13 '18 at 4:41
  • where is your code located? – cjbj Mar 13 '18 at 19:08
  • This code was in my header.php, but the solutions below. – Galgóczi Levente Mar 14 '18 at 3:58
2

If first check in your header.php file and check in title tag what is print. if in title tag bloginfo then it's replace with wp_title('') because bloginfo is not replace with code.

Header.php

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

After function.php file put this code:

    function wpdocs_theme_name_wp_title( $title, $sep ) {
    if ( is_feed() ) {
        return $title;
    }

    if (  is_home() || is_front_page() )  {
        return $title;
    }

    global $page, $paged;

    // Add the blog name
    $title .= bloginfo( 'name' );

    // Add a page number if necessary:
    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
        $title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) );
    }

    return $title;
}
add_filter( 'wp_title', 'wpdocs_theme_name_wp_title', 10, 2 );

NOTE: your title tag is blank then in tab display your SITE URL.

  • Thank you, it finally turned out the problem was caused by the All In One SEO plugin, but I knew that, because I trying to follow your intructions, because my theme dont used nor bloginfo, nor wp_title('') in the header. – Galgóczi Levente Mar 13 '18 at 6:15
0

If you using All In One SEO Pack and dont working for you Patel Jignesh's solution, your problem originate from the plugin. I just managed to solve it, that I updated the core file: all-in-one-seo-pack/aioseop_class.php row 1612. Change this (on row 1612):

 $title = $this->internationalize( get_option( 'blogname' ) ) . ' | ' . $this-
 >internationalize( get_bloginfo( 'description' ) );

To your preferred title, example:

     $title = '' . get_bloginfo( 'name' ) . ' | Your Network Title';

My situation is isolated, because if dont need for you at all events dinamically generating the home page title and description with AIOSEP on your subsites, you can do simply write your and your client's subsites seo titles in the plugin's general settings.

But, if you are in a similar situation, I recommend you call the subsite's description on your theme's header file, because counter to the title, the AIOSEP dont generate description if the $description is empty, so your subsites home's will dont have meta descriptions. (Otherwise even though I like this plugin, dont clear for me, why calling the get_bloginfo( 'description' ) in the home_title, that the $title (and also the $description) is empty, instead of it fill in both metas...)

Use this code in your header:

 if ( is_front_page() || is_home() ) {
    $homedesc = 'description';
    echo '<meta name="description" content="' . get_bloginfo( '' . $homedesc 
    . '' ) . '" />';
    }

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.