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:
- How to create a custom search for custom post type?
- 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
- Using standard search function with custom post type
- 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
- Search Custom Post Type with all meta attached?
- 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?
- Customize Search to only search current custom post type
- Include different loop templates in search query
- Search tags in CPTs
- How to search CPT’s by meta query from the admin dashboard?
- 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
- Searching Custom Fields
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- How to let users choose where to search for posts?
- Can NOT search my custom post type?
- Custom post_type search pages
- Pagination Error : Duplicate argument being outputted
- WordPress search and date filter not working with custom post type
- Custom Empty Results page for my Custom Post Type
- Custom filter for main search: how to exclude specific post_type from search results
- Display an icon based on post type
- how to get this tax_query working?
- Select2 AJAX and WP Query Returns ALL and does not filter
- 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]
- Searching post types
- CPT, meta-data, url parameter
- Search CPT Title AND Meta
- Building a Data Intensive Website with WordPress
- Display future posts in search
- Modifying search results based on post_type
- Is it possible to get the specific content on the search page?
- Change search query in wordpress custom post type
- Search for custom field input of a custom post type in ajax live search
- 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
- Advanced search form with multiple custom fields
- Custom Archive – hide posts until a search is made?
- 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
- 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
- Search facility with directories
- Create Second Search Page Only for Custom Post Type
- 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
- Custom Post Search
- pre_get_posts not firing at all
- Custom Search not working
- Search page for custom post type
- 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
- Archive custom template from search
- search this custom post type
- Why does ‘exclude_from_search’ exclude a custom post type from WP_Query?
- Custom post archive with search, is_search() is false?
- 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
- Get a custom post type’s taxonomy type term names displayed as checkboxes and filter
- How to Display Content from Search URLs on Permanent URLs in WordPress?
- Exclude multiple custom post types from search