It is possible and even advisable (in most cases) to prevent search engines from indexing the search results pages on WordPress sites.
You would want to do this in order not to waste crawl budget on pages that do not need to be indexed and also so that they do not appear in your Google Search Console Index Report.
Adding the following instructions to the robots.txt file will request Google and other search engines not to index the WordPress search results pages, assuming you have not made a special change to the functionality of the WordPress search mechanism.
Here is the code you need to add to the robots.txt
file located in the root directory of the site:
User-agent: *
Disallow: /?s=
Disallow: /search/
Alternatively, if you are using the WordPress SEO by Yoast plugin, you can perform the same action through your site’s dashboard. Go to Yoast SEO in the admin interface and click on “Settings“.
Go to the “Advanced” tab and click on the “Crawl Optimization” option. Now under the section “Internal site search cleanup“, activate the option “Prevent crawling of internal site search URLs“.
So far, questions and comments are welcome…