Noindex Thin Archive Pages
Adds noindex, follow to date archives, attachment pages and page 2+ of archives, so search engines focus on your real content.
Opens WPIDE on
Code
add_filter( 'wp_robots', function ( $robots ) {
if ( is_date() || is_attachment() || ( is_paged() && ( is_archive() || is_home() ) ) ) {
$robots['noindex'] = true;
$robots['follow'] = true;
}
return $robots;
} );
Notes
Skip this snippet if an SEO plugin already controls robots meta tags.
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.