Home / posts / Search a specific post type
  • How to Search a specific post type

    no thumbnail sorry: Search a specific post type

    Adding this PHP cde to your wordpress theme will allow you to search specific post types.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    function SearchFilter($query) {
      if ($query->is_search) {
        // Insert the specific post type you want to search
        $query->set('post_type', 'feeds');
      }
      return $query;
    }
    // This filter will jump into the loop and arrange our results before they're returned
    add_filter('pre_get_posts','SearchFilter');
    

    ( WordPress codex functions, hooks, in this snippet. )

    query, get_post, get_posts, add_filter, is_search,