This is not related only to your custom post_types search. WordPress has a problem on empty search on itself. I use this simple code snippet as workaround:
add_filter( 'request', 'my_request_filter' );
function my_request_filter( $query_vars ) {
if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) {
$query_vars['s'] = " ";
}
return $query_vars;
}
You may tak advantage of that and build your own code above that.
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?
- 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 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
- How to search from specific post type with tags?
- custom search result page
- How to search CPT’s by meta query from the admin dashboard?
- Customize Search Results for Custom Post Type
- multiple search forms and search results
- Custom Fields vs Separate Table
- How to create an advanced filter search?
- How to search map address in custom post type?
- Custom Search for Drafts in Custom Post Type
- 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
- 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?
- Auto Complete Search
- Remotely search WordPress sites using xml-rpc
- BBPress Search results in WordPress search
- Limit Search to Post Type With Apostrophe return search not found
- Search filter triggered & sort by custom post type
- Set Custom Post Type in Widget Settings for use in Widget
- Displaying and searching Custom Posts
- Search by tag name and category
- Advanced search form with filters for custom taxonomies
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Different results between permalink and query var search
- How to let users choose where to search for posts?
- WordPress Custom Search by post_type
- What content types are shown at a search page?
- Pagination Error : Duplicate argument being outputted
- Custom Empty Results page for my Custom Post Type
- Select2 AJAX and WP Query Returns ALL and does not filter
- search custom post type by custom fields on front end
- Custom Search | check multiple meta_value for search value
- Searching post types
- Blank search results on custom search
- Limit search field to just search a custom post type with custom fields
- Building a Data Intensive Website with WordPress
- Display future posts in search
- Search custom type post
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Is it possible to get the specific content on the search page?
- Search for custom field input of a custom post type in ajax live search
- Creating a custom WP query for a Custom Post Type
- In the php, how can I have a category of a custom post type display?
- Search Function not searching correct custom_post_type even though post_type is defined in search args
- search results to show individual ACF fields from inside custom posts
- Live search by custom tag
- Custom search for a custom post type in WordPress
- Advanced search form with multiple custom fields
- Search in multiple specific post types
- I can not display search template created from a post type custom
- Creating a search results page from a custom post type in a plugin?
- Search custom post type result in same template page
- Search facility with directories
- Create Second Search Page Only for Custom Post Type
- custom search form for custom post
- Custom post url in search.php isn’t the correct rewrited url
- Conditional posts in WP_query for search
- Manually build WP_Query
- Trying to modify custom search function in plugin to search postmeta table for keyword as well as posts table
- pre_get_posts not firing at all
- Custom post type blog pagination conflict
- Diffrent search templates for different post types
- Searching for a single custom post type, buddypress
- admin search of pages returns custom post types
- How do I do this?: If custom post type exists, echo it, else do not
- Searching Custom Posts content with JQuery
- Custom Field Search
- Why custom search engine only searches in post titles of custom posts?
- How do I provide a search form for a specific post type, that is capable of searching within custom fields of the specified CPT?
- Meta_query question
- Multiple search forms and respective results page templates?
- Get a custom post type’s taxonomy type term names displayed as checkboxes and filter
- Exclude multiple custom post types from search
- Search for portfolio tags & mixing portfoliotags and post tags
- How do I create a custom search function to only show contact information if they search for an exact unique identifier?