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?

2 Answers
2

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.

Leave a Reply

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