Hi,
I need to exclude one of the pages from the search result. Right now I am using 'post__not_in' like this
function my_search_filter($query){
if($query->is_search){
$query->set('post__not_in', array(5));
}
return $query;
}
add_filter('pre_get_posts','my_search_filter');
But is there any way to exclude pages from the search result based on their slugs or contents? For example, can I exclude a page having the slug 'news' or the content '[this-will-be-replaced-by-my-plugin]'?
Thanks in advance.