Noindex Paginated Archives With All in One SEO
Adds noindex to page 2 and later of archives through All in One SEO's robots meta while keeping links followed.
Opens WPIDE on
Code
add_filter( 'aioseo_robots_meta', function ( $attributes ) {
if ( is_paged() && is_array( $attributes ) ) {
$attributes['noindex'] = 'noindex';
unset( $attributes['index'], $attributes['nofollow'] );
}
return $attributes;
} );
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.