Noindex Page 2 and Beyond With Yoast
Tells search engines not to index paginated archive pages (page 2, 3 and so on) while still following their links, using Yoast SEO's robots meta.
Opens WPIDE on
Code
add_filter( 'wpseo_robots_array', function ( $robots ) {
if ( is_paged() && is_array( $robots ) ) {
$robots['index'] = 'noindex';
$robots['follow'] = 'follow';
}
return $robots;
} );
Notes
The first page of every archive stays indexable.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.