2

After switching to a different wordpress theme, Google started adding a sitename to ALL page titles in the search results.

E.g.:

"Page title - Sitename"

Even when leaving the sitename area blank, Google still adds the homepage title next to every single page. This only started hapening after I switched to my new current wordpress theme.

I am using the Yoast SEO Plugin and even tried removing "%%sep%% %%sitename%%" in the settings, but still doesn't work.

I contacted the theme developer, this was his response:

"The theme doesn't set any custom title. It uses default add_theme_support( 'title-tag' ); wordpress function and Seo by Yoast works with this."

How can I remove the sitename? Do I need to change the header.php code? If not which code should I edit?

  • Can you post a link to the current site, or copy and paste a snippet from the header.php showing <title>so that we can see more information? – Monkey Puzzle Apr 11 '16 at 12:36
4

By default WordPress use _wp_render_title_tag to hook wp_head ( see here )

add_action( 'wp_head', '_wp_render_title_tag', 1 );

This function is wrapper of wp_get_document_title to show title tag on theme if add_theme_support( 'title-tag' ); added in theme file functions.php ( commonly ). https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/general-template.php#L944

If you see filter document_title_parts on function wp_get_document_title(), we can filter parameters that used in title ( title, page, tagline, site ).

Let say if we need to remove site name title part of homepage and single post, you just need to unset parameter title and site with conditional tags, here the sample code ( add in functions.php theme file ):

add_filter( 'document_title_parts', function( $title )
{
    if ( is_home() || is_front_page() )
        unset( $title['title'] ); /** Remove title name */

    if ( is_single() )
        unset( $title['site'] ); /** Remove site name */

    return $title;

}, 10, 1 );

About your issue in Google indexing, it's off-topic here.

0

In your header.php you may need to replace:

<title><?php whatever code you find in your existing theme ?></title>

with:

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

Make sure you make a copy first so you can revert back if you need to!

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.