If you have hidden pages on your blog, you may want to hide them from search results too. Here is a little trick to hide them all.

This trick uses pre_get_posts filter to remove pages from the query results. Here is the code:

// Remove pages from search results
function shailan_remove_pages($query){
	if ($query->is_search){
	return $query;

Open your functions.php file and put this snippet in. Save and upload.

After the edit is done, you can test it out by searching a page title.

This way you can make sure no pages are listed on your search results page.

Hope you like this trick. Enjoy!