I found how to exclude ALL pages from search results by adding the code below to the functions.php editor, but I want to only exclude one or two pages from search results.
<?php
function mySearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','mySearchFilter');
?>
I've been unsuccessful trying to Google a solution, so could you please suggest some coding?
thank you
Tracy