Noindex paginated pages in Yoast SEO

Since the version 7.0 the most downloaded and popular WordPress Plugin – Yoast SEO started paginated pages indexation by default. Meaning search engines like Google will index your paginated pages.

For example: “/page/2/” or “/page/3/” etc pages will be indexed by search engines by default. Previously you could disable it from the settings of Yoast SEO plugin but that is no longer the case.

Some like it, some don’t. Personally I don’t like this at all. I don’t like unwanted pages to be indexed by search engines because it’s hurts SEO of your actual posts. Fortunately you can disable it by adding some few line of code in the theme’s function.php of your WordPress setup.

The following code will automatically add “noindex” tag on the paginated pages, hence the search engines not going to index them. If they already did index them, they’re gonna noindex them soon.

// no-index tag for paginated pages for Yoast SEO => 7.0
add_filter( 'wpseo_robots', 'no_index_paginated_pages' );
function no_index_paginated_pages( $string ) {
    if ( is_paged() ) {
        return 'noindex, follow';
    } else {
        return $string;
    }
}

Once you added them you can check if the code is working by looking into the source code of a paginated pages. I hope this helps.

Share your thoughts by leaving a comment below.