Categories
Search WordPress

WordPress Exclude pages from search

function chet_tips_modify_search_filter($query) {

  if ($query->is_search) {

    $query->set('post_type', 'post');

  }

  return $query;

}

add_filter('pre_get_posts','chet_tips_modify_search_filter');

Leave a Reply

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