Categories
tips

WordPress adds “robots noindex” meta tags for search result pages, here’s how to disable it

Recently I noticed Google dropped a huge chunk of pages containing search results.

Recently I noticed Google dropped a huge chunk of pages containing search results.

I debugged and dug through the code and found the culprit

<meta name=’robots’ content=’noindex, follow, max-image-preview:large’ />

To remove this tag for search pages only, add this code to your theme’s functions.php

remove_filter( ‘wp_robots’, ‘wp_robots_noindex_search’ );

To remove all the other Robots API tags

remove_filter( ‘wp_robots’, ‘wp_robots_max_image_preview_large’ );
remove_filter( ‘wp_robots’, ‘wp_robots_noindex’ );
remove_filter( ‘wp_robots’, ‘wp_robots_noindex_embeds’ );

It’ll still pop out in pages that reply to comments i.e. with the parameter replytocom.

I hope it helps someone.

Leave a Reply

Your email address will not be published. Required fields are marked *