Keep search results pages out of Google
Your site’s search results pages tell search engines not to index them. They’re thin, endless and a favourite of spammers who link to searches.
<?php
add_filter(
'wp_robots',
static function ( $robots ) {
if ( is_search() ) {
$robots['noindex'] = true;
$robots['follow'] = true;
}
return $robots;
}
);
In these packs
- SEO basics: Meta descriptions, social sharing tags, article structured data and cleaner indexing, for sites without an SEO plugin.