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 );
Related Posts:
- How to create a custom search for custom post type?
- Extending the search context in the admin list post screen
- Include custom taxonomy term in search
- Creating a search form for custom fields
- Searching multiple custom post types and pages
- AJAX search on post pages by custom post type
- How can I change the admin search posts fields?
- How to make a WP_Query search with custom post types?
- group search results by post type?
- Development of a WordPress Search Plugin – Best Practices
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Simple way to search custom-post types only
- Pushing a custom post type to the top of the search results
- Custom post type admin search
- Using standard search function with custom post type
- Search that will look in custom field, post title and post content
- Seperating Custom Post Search Results
- Search everything (posts, pages, tags, cpt, meta)
- Search Custom Post Type with all meta attached?
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- filter search result with custom post type meta key
- Custom search for custom post type, custom meta and search fields
- Search Post Title Only [duplicate]
- Customize Search to only search current custom post type
- Auto Draft Specific Categories Posts after a certain number of Days
- How to search from specific post type with tags?
- No results searching custom post type in admin panel
- custom search result page
- How to search CPT’s by meta query from the admin dashboard?
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Customize Search Results for Custom Post Type
- multiple search forms and search results
- error in Advanced Search Form for Custom Post Types in WordPress array_key_exists() expects parameter 2to be array, string given
- Search Custom Post Type Custom Fields
- Custom Fields vs Separate Table
- How to create an advanced filter search?
- How to search map address in custom post type?
- WooCommerce product search titles only
- custom post type Search returns No Results in admin panel
- Search Custom Post Type & Taxonomies
- Multiple meta_values in the pre_get_posts filter?
- How to order separated Custom Post Search results
- Custom post type search using $_SESSION and pre_get_posts
- How to stick custom post at the top in search results
- filter custom post type by meta key in dashboard
- Can I search only some of the fields of a custom post type?
- Make parts of your wordpress website completely built with data from external APIs?
- Custom post type not showing in search result
- What to and how to proceed with CPT to make DB small and efficient?
- Pretty URL for custom search for custom post type
- Add post location with mile radius allowing search
- Auto Complete Search
- Remotely search WordPress sites using xml-rpc
- Limit Search to Post Type With Apostrophe return search not found
- Searching Custom Fields
- Can NOT search my custom post type?
- Custom post_type search pages
- WordPress search and date filter not working with custom post type
- Custom filter for main search: how to exclude specific post_type from search results
- Add custom attributes to a post
- Display an icon based on post type
- how to get this tax_query working?
- Custom Taxonomy Search result page
- How to group search results by post type and only if post type result is not empty?
- find custom post type post by searching its custom field with my string
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- What is the correct term for a tool that filters content based on metadata?
- Ideas on how to organize a project [closed]
- Filtering custom posts by custom fields (ACF) [closed]
- CPT, meta-data, url parameter
- Custom post type draft use wrong template
- Search CPT Title AND Meta
- Modifying search results based on post_type
- How to Implement Search Functionality?
- Change search query in wordpress custom post type
- Updating a custom post status after an expiry date rather than trashing it
- Create a post automatically if search result has zero results
- Search only one custom post type
- Query first and last name from custom post type
- Custom Archive – hide posts until a search is made?
- Display result as “prefix+ID” and show in the search result as bookcode
- Include images from pages in wp search.php results in default wp search
- custom search results – order results differently by post type
- Post search not looking at post title since 4.4.2 upgrade
- Custom Post Search
- Search form to find custom meta box generated data
- 404 error Custom search results page for custom post types with friendly URL
- multiple custom post type category selection search
- Custom Search Template for Custom Post Types
- Custom Search not working
- Search page for custom post type
- Is it good practice to search for custom posts based on custom field values?
- Cannot get query var ‘post_type’ to work
- Archive custom template from search
- Customising wordpress search and using $_GET[“s”]
- search this custom post type
- Group search results by post type, but having a unique heading for each section?
- Fix Custom Post Type not appearing in search results?
- Search and filter terms of a custom post type only and display results
- How can I retain get_post_type() in between consecutive searches after a search returns no results?