Home>

I want to display a separator in the page title of the article page when it appears in google search results.

Theme used: http://lionmedia.fit-jp.com/
wp version: 4.9.3

Error message

It is the page title of the article page when it appears in google search results, etc., but it is currently displayed as follows.
"Title of article title space site name"

I added the following code to function.php in the small theme to change this space to "|".

// Title separator
function change_separator () {
    return "|";// write the delimiter I want to change here
}
add_filter ('document_title_separator', 'change_separator');


Reference site: https://joyplot.com/ documents/2016/09/07/wordpress-title-separator/

However, it is reflected in the title tag of the article page, but it is not reflected in the title displayed in the google search results.

Please tell me how to apply it to the search results.

All small theme function.php
<? php
//////////////////////////////////////////////////
// Load parent theme style.css
//////////////////////////////////////////////////
function fit_head_child () {
    if (get_option ('fit_seo_cssLoad-main')) {
        echo '<link rel href = "'. get_template_directory_uri (). '/ style.css">'. "\ n";
    } else {
        echo '<link rel = "stylesheet" href = "'. get_template_directory_uri (). '/ style.css">'. "\ n";
    }
}
add_action ('wp_head', 'fit_head_child');

//////////////////////////////////////////////////
// User customization area below
//////////////////////////////////////////////////
// Change the three-point leader displayed when the text of the article on the top page exceeds the specified number of characters to any character
// give return as return value
function my_excerpt_more ($more) {
    return '…';
}
add_filter ('excerpt_more', 'my_excerpt_more');
// Heading at the top of the lower page
function fit_archive_title__child () {
    $title = get_bloginfo ('name');
    if (is_category ()) {
        $title = '". single_cat_title (' ', false).'" Category List ';
    } elseif (is_tag ()) {
        $title = '". single_tag_title (' ', false).'" Tag article list ';
    } elseif (is_author ()) {
        $title = 'List of articles posted by' '. get_the_author ().' ';
    } elseif (is_year ()) {
        $title = 'List of articles posted on' '. get_the_date (' Y ​​year ').' ';
    } elseif (is_month ()) {
        $title = 'List of articles posted on' '. get_the_date (' Y ​​year n month ').' ';
    } elseif (is_day ()) {
        $title = 'List of articles posted on'. get_the_date ('Y year n month j day'). '";
    } elseif (is_search ()) {
        $title = 'Search results for' .get_search_query (). '': ';
    } elseif (is_404 ()) {
        $title = 'The page you were looking for could not be found (404 error)';
    }
    return $title;
}
// read js
function my_scripts_method () {
    wp_enqueue_script (
        'custom-script',
        get_stylesheet_directory_uri (). '/ js/custom.min.js',
        array ('jquery'),
        '1.0',
        true
    );
}
add_action ('wp_enqueue_scripts', 'my_scripts_method');
// Reflect the customized css in the visual editor
add_editor_style ('style-editor.css');
remove_filter ('the_title', 'wptexturize');
remove_filter ('the_content', 'wptexturize');
remove_filter ('the_excerpt', 'wptexturize');
// title separator
function change_separator () {
    return "|";// write the delimiter I want to change here
}
add_filter ('document_title_separator', 'change_separator');
  • Answer # 1

    The modified data may not be indexed yet.
    If you wait or hurry, try to crawl again.

    Request Google to crawl URLs-Search Console Help

    It ’s good to know that Google may rewrite.