• Hello,

    how to delete the word Archive from search results in google? The word will appear at the beginning. Just before Title.

    Regards

Viewing 1 replies (of 1 total)
  • Hi
    The page title on category pages (Archives) is generated by the get_the_archive_title() function which adds ‘Category’, ‘Tag’ or ‘Author’ to the title.
    The output of this function can be filtered to remove the relevant word by placing this in your themes functions.php file:

    function my_theme_archive_title( $title ) {
        if ( is_category() ) {
            $title = single_cat_title( '', false );
        } elseif ( is_tag() ) {
            $title = single_tag_title( '', false );
        } elseif ( is_author() ) {
            $title = '<span class="vcard">' . get_the_author() . '</span>';
        } elseif ( is_post_type_archive() ) {
            $title = post_type_archive_title( '', false );
        } elseif ( is_tax() ) {
            $title = single_term_title( '', false );
        }
      
        return $title;
    }
     
    add_filter( 'get_the_archive_title', 'my_theme_archive_title' );

    However if you are meaning the Page title that appears in the browser tab and at the top of the Search results output you can either use a function that will filter the output or a plugin.
    The title is generated by the wp_title() function the output of which can be filtered as follows:

    function rewrite_archives_title($title, $sep)
    {
        // replace the string Archives with nothing
        return preg_replace("/Archives/", "", $title);
    }
    add_filter("wp_title", "rewrite_archives_title", 11, 2);

    If you want to use a plugin the Yeost SEO plugin allows you to define the page titles.
    The plugin is here:
    https://wordpress.org/plugins/wordpress-seo/
    Go to Dashboard > SEO > Titles & Meta > Taxonomies and you will see that you can change the structure of the page titles.
    By default the title includes:
    %%term_title%% Archives %%page%% %%sep%% %%sitename%%

    So you can remove the ‘Archives’ bit leaving the following:
    %%term_title%% %%page%% %%sep%% %%sitename%%
    I hope that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Archive’ is closed to new replies.