Not every URL on your WordPress site is worth indexing. Search result pages are generated dynamically for every query a visitor types, creating an infinite number of URLs with thin, duplicate-prone content. Paginated archive pages beyond the first, /page/2/, /page/3/, contain the same metadata as the first page with a different subset of posts, and rarely carry enough unique value to warrant independent indexing. Letting Google index these pages wastes crawl budget and can introduce thin content signals that dilute your site’s overall quality assessment.
This snippet adds a noindex, follow meta tag to these page types, telling Google not to include them in its index while still following any links found on those pages.
The Code
Add this to your functions.php or a site-specific plugin. The hook runs at priority 1 to ensure the meta tag appears early in the head. Three conditional checks cover the most common sources of non-indexable URLs.
noindex vs noindex, follow
The snippet uses noindex, follow rather than noindex, nofollow. The distinction matters: follow tells Google it’s still allowed to crawl links it finds on these pages and pass link signals through them, even though the page itself won’t be indexed. nofollow would prevent link equity from flowing through any links on these pages, which is rarely what you want on paginated archives that link to individual posts.
Search Pages
WordPress search results at /?s=query or /search/query/ are some of the most commonly indexed thin content pages. Every unique search term creates a new URL. These pages have no unique content of their own, they’re just subsets of your existing posts filtered by keyword, and offer no value to Google’s index. Noindexing them is a universally recommended best practice.
Paginated Archives
The first page of any archive, /blog/, /category/news/, has genuine value and should be indexed. Pages 2 and beyond are where the tradeoff becomes less clear. On large sites with strong domain authority, deeper paginated pages may receive organic traffic and link equity. On most sites, the content is too diluted and the pages too deep to meaningfully rank. is_paged() returns true only on pages 2 and beyond, leaving page 1 unaffected.
Interaction with SEO Plugins
If you use an SEO plugin like SlimSEO, Yoast, or RankMath, check whether it already handles noindexing for these page types before adding this snippet, duplicating the meta tag isn’t harmful but is unnecessary. SlimSEO automatically noindexes search pages. Yoast has a per-archive noindex setting. Running at priority 1 means this snippet’s output appears before most SEO plugin output, but both tags will be present in the head if the plugin also outputs one.
add_action( 'wp_head', function() {
$should_noindex = false;
// Noindex search results
if ( is_search() ) {
$should_noindex = true;
}
// Noindex paginated pages beyond the first
if ( is_paged() ) {
$should_noindex = true;
}
// Noindex 404 pages
if ( is_404() ) {
$should_noindex = true;
}
if ( $should_noindex ) {
echo '<meta name="robots" content="noindex, follow">' . "\n";
}
}, 1 );
