WordPress Exclude categories from search

function chet_tips_search_filter($query) {

  if ( $query->is_search && ! is_admin() ) {

    $query->set('cat','8,15'); 

  }

  return $query; 

}

add_filter('pre_get_posts','chet_tips_search_filter');

Leave a comment

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

%d bloggers like this: