Paulund
2012-01-17 #wordpress

Stop Search Engines From Indexing Search Results

On your search pages of your Wordpress you want to make sure that these are not indexed by the search engines. Having these indexed might create duplicate entries in the search engines compared to your category or archive pages. Here is a quick Wordpress snippet to stop the search engines from indexing these pages, add the following into the head tag of theme.


<?php if(is_search()) { ?>
   <meta name="robots" content="noindex, nofollow" />
<?php }?>

This uses the is_search function which will return true if you are on the search page. Then we can add a meta tag which will tell the search engines if you do land on this page don't index the page and don't follow any of the links of the page. Having both these in the meta robots tag will mean that the crawler will not go over the page and will crawl the next page.