Tell search engines not to index date archives, author archives on single-author sites and empty tag pages, using WordPress's robots API.
add_filter( 'wp_robots', function ( array $robots ): array {
$noindex = false;
// Date archives (/2026/11/) usually duplicate your normal archives.
if ( is_date() ) {
$noindex = true;
}
// Author archives duplicate the blog on sites with only one author.
if ( is_author() && count( get_users( [ 'capability' => 'edit_posts', 'has_published_posts' => true, 'fields' => 'ID', 'number' => 2 ] ) ) < 2 ) {
$noindex = true;
}
// Tag pages with fewer than 3 posts are thin.
if ( is_tag() && get_queried_object()->count < 3 ) {
$noindex = true;
}
if ( $noindex ) {
$robots['noindex'] = true;
$robots['follow'] = true;
}
return $robots;
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
WordPress creates archive pages for every date, author and tag. Many of them repeat the same posts as your main blog pages or list just one or two posts. This snippet tells search engines not to index those, while still following their links.
Since version 5.7, WordPress builds the robots meta tag through the wp_robots filter. The snippet adds noindex, follow to:
/2026/11/.The previous version printed its own robots tag, which created a second, conflicting tag next to the one WordPress already prints. It also noindexed search results, which WordPress already does by itself, and paginated archives like /page/2/. Google no longer recommends noindexing paginated pages, because they’re how crawlers find your older posts.
Open a date archive such as yoursite.com/2026/, view the source and search for name='robots'. You should see one tag containing noindex, follow. A normal category page should not have it.