How to exclude WordPress posts or pages from search results

This snippet will allow you to control which posts or pages there should be excluded from WordPress search results.

Add this code to your functions.php file.
* In this snippet, posts with the IDs 0 and 1 will be excluded – edit accordingly to suit your needs.


Leave a Reply

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