It's possible to search within drafts by setting the post_status
argument to draft
in your search query, however, a better option is to control things with the arguments passed to register_post_type
.
We first set public
to false, which will hide the post type everywhere- front and back end. We then selectively enable show_ui
to get the admin UI, and set exclude_from_search
to false
so they show up in front end searches.
You will then have published posts that are searchable, but they will have no individual pages on the front end.
$args = array(
'public' => false,
'show_ui' => true,
'exclude_from_search' => false,
'label' => 'Name',
// your other arguments...
);
register_post_type( 'name', $args );