Hi team,
I’d like to noIndex search results pages.
The following code in functions.php no longer works (from this thread):
add_filter('avf_set_follow','avia_set_nofollow');
function avia_set_nofollow(){
if ( is_search() ) {
$meta = '<meta name="robots" content="noindex, follow" />' . "\n";
}
return $meta;
}
Any idea why or what I can do instead?
Thanks,
Joe
You could install Yoast and just set every page/post you need no-indexed to that setting.
You could also discourage search from your WP settings.
Hi,
Thanks for trying to help @fraggs.
Unfortunately, it’s not what I’m looking for. The code is supposed to mark search results pages as noIndex. This is to prevent a non-self-referential canonical links and to prevent search results pages from appearing in search egnine indexes. This is for SEO purposes. Discouraging search engines would be pretty bad for SEO.
I’m not aware that you can noIndex search URLs or URLs with a specific query string (such as, in this case, those containing “?s=”) using Yoast, but please tell me if that’s not correct.
@john, is the avf_set_follow filter still supposed to work as intended?
Many thanks,
Joe
Hi,
Try add the code at header simple, would that work? I mean using the wp_head hook
Best regards,
Basilis