The only way I could figure it out was to build a list of ID’s to exclude like this:
/*
* Hide some pages from search results
*/
function SearchFilter($query) {
if ($query->is_search) {
$exclude="18,20,12,22,132,76,81,78,84,91";
// Get all children of #18
$pages = get_pages('post_parent=18');
foreach($pages as $child) {
$exclude .= "," . $child->ID;
}
$query->set('post__not_in', explode(",", $exclude));
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
You could use any of the WP_Query parameters to do similar things (like a build a list of ID’s to include).