Skip to main content
2 of 2
added 26 characters in body
Milo
  • 78.8k
  • 4
  • 127
  • 168

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. We also set rewrite to false, so WordPress doesn't generate rewrite rules for this post type.

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,
    'rewrite' => false,
    'label' => 'Name',
    // your other arguments...
);
register_post_type( 'name', $args );
Milo
  • 78.8k
  • 4
  • 127
  • 168