You can use get_query_var() to access the post type that was used for the search, and then add that as a hidden field on the search page.
Untested:
printf(
'<input type="hidden" name="post_type" value="%s" />',
get_query_var( 'post_type', get_post_type() )
);
Related Posts:
- Advanced search form with filters for custom taxonomies and custom fields
- Creating a search form for custom fields
- Search multiple custom fields by using meta_query
- Custom post type admin search
- Have different search results template depending of custom post type searched
- The right way to create a custom search page for complex custom post types
- Include images from pages in wp search.php results in default wp search
- Separating Search Results By Post Type
- WordPress Admin Panel search posts with custom post meta values along with title
- Backend search; include CPT meta?
- Custom Search form not working in localhost
- Custom Search | Wrong output & question
- Limit search form to 4 custom post types only
- Group search results by post type, but hide post types with no results
- Search results ordered by custom post types are not grouped
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- How can I include meta box content when searching?
- Include different loop templates in search query
- Search tags in CPTs
- Set meta_query only for specific post type
- Add custom post type archives to search results?
- CPT Meta Searching
- CPT Search Form with Taxonomy filter & Or
- How to filter search results by post type?
- Custom search results page query, link permalink to post title while separating by post types
- Including Custom Meta with posts_where query
- search also in taxonomy, tags and custom fields
- Custom Post Type And “fopen”
- Filter custom posts using auto populated dropdown selectors
- Including metaboxes from custom post types in global search — continued
- Include custom post type content in search
- Get post count for search result based on post type
- search suggest – filter post type
- Searching Custom Post Types
- How do i search authors from search form using author’s name
- 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
- Searching Custom Fields
- 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?
- Can NOT search my custom post type?
- Custom post_type search pages
- 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
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Custom Search | check multiple meta_value for search value
- Filtering custom posts by custom fields (ACF) [closed]
- Searching post types
- Blank search results on custom search
- Limit search field to just search a custom post type with custom fields
- Search CPT Title AND Meta
- Building a Data Intensive Website with WordPress
- Display future posts in search
- Modifying search results based on post_type
- 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
- 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 only one custom post type
- Query first and last name from custom post type
- 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
- Include images from pages in wp search.php results in default wp search
- 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
- custom search results – order results differently by post type
- Conditional posts in WP_query for search
- Post search not looking at post title since 4.4.2 upgrade
- 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 Search not working
- Custom post type blog pagination conflict
- Is it good practice to search for custom posts based on custom field values?
- Diffrent search templates for different post types
- Cannot get query var ‘post_type’ to work
- Problem with custom post type search
- admin search of pages returns custom post types
- Why does ‘exclude_from_search’ exclude a custom post type from WP_Query?
- Custom Field Search
- Custom post archive with search, is_search() is false?
- Group search results by post type, but having a unique heading for each section?
- How to exclude html tags and class on search
- Multiple search forms and respective results page templates?
- Fix Custom Post Type not appearing in search results?
- Search and filter terms of a custom post type only and display results