//Exclude category from WordPress Search
function wcs_exclude_category_search( $query ) {
  if ( is_admin() || ! $query->is_main_query() )
    return;

  if ( $query->is_search ) {
    $query->set( 'cat', '-25, -26, -27, -28' );
  }

}
add_action( 'pre_get_posts', 'wcs_exclude_category_search', 1 );