I believe something like this would do the trick.
EDIT
My code assumes the querystring value is the post_type, not an integer like your form field. Also, your form field is named ‘cat’, I think WordPress has that reserved, at least I remember having conflicts when I last used ‘cat’ in a querystring.
EDIT 2
(Changed filter from ‘posts_where’ to ‘pre_get_posts’ after having done some tests)
In functions.php
function my_filter( $query )
{
if( is_search() )
{
$type = ( !empty( $_GET['your-field'] ) ) ? $_GET['your-field'] : "";
if( $type )
$query->set( 'post_type', $type );
}
}
add_filter( 'pre_get_posts', 'my_filter' );
Related Posts:
- Filter results with custom field values and dropdown
- Search results sorted by post types
- custom wp_dropdown_categories items in wordpress
- Search wordpress using three different drop down menus
- Add Search Form to Dropdown menu
- Hightlight search-terms with functions does remove or disable other filters?
- How can I implement a location based (zip code) search in WordPress?
- How to highlight search terms without plugin
- Template issues getting ajax search results
- Complex Search functionality. Advice needed
- How to use next_post_link and previous_post_link on single posts in search results
- Why is there a class=”screen-reader-text” on my search button?
- can’t limit search to only pages
- How to exclude post body from WP search
- ElasticPress Indexing multiple sites
- Search outside of the “loop”
- Replace URL with Site Title in Search Results
- Force WP to use a certain search template
- Best way to Integrate Google Search?
- Related Tags Concept
- How to add additional search terms (e.g. synonyms) to the search?
- Combine internal search with Google custom search?
- Any reason why search result lists only one entry?
- Custom search form to display users only
- Display just child pages of a certain page in search results
- How to make wordpress default search to woocommerce search
- pre_get_posts action: Search by post_title and post_content with different search phrase in the same query
- Why won’t is_search work inside functions.php?
- WooCommerce product search titles only
- Search functionality – include date, category and author search
- WordPress Search matching hyphenated words
- How to stop WordPress Search form from searching only in current page?
- filter custom post type by meta key in dashboard
- WordPress sort search results by custom order
- Change Search url slug for each site in a multisite network
- URL search link for ‘category__and’ instead of php query
- Display filtered results into custom page
- Get parent and children taxonomy in different dropbox
- Search media by title and description – Frontend
- Is there a way to add a custom text + link above search results for different searches?
- How to change tab’s title in search results pages? [closed]
- Customise Excerpt start and end
- Template issues getting ajax search results
- How can I implement Search feature for Membership site?
- WordPress search with quotations returning to homepage
- Refine/Filter the Search Results by Category
- How to display search results in search.php
- Search WooCommerce Products in WordPress
- Strip HTML Tags From Search Results
- some one help . search not jump to search page
- Why should we use the name attribute with the value “s” in the creation of the search form?
- The Search FoRM Dilemma || The Search form Templating
- Search for anything in site
- How can I add search box in single.php?
- Independent search tool that returns exact match of a post title
- Connecting Google Site Search with WordPress Taxonomies/Categories/Tags
- Only display post content in search results
- meta post search
- search page not found? (search.php or searchpage.php)
- conditional search
- Media Library / Backend: How can I search for text in the ALT Text field?
- Rewrite wp function
- How to fetch Email addres of an author via ID?
- How to Fix Form elements do not have associated labels in WordPress Search Form (without button)
- Search within the current page
- How to exclude specific post_type from default search?
- What are the available options for “Name” in WP search?
- Search issue on special Character
- Modify main search form to search user too
- Dropdown Select Post Filter
- Removing &submit=Search from search parameters?
- show only one category and filter by tag
- customize search result in wordpress
- meta box loop problem with a search filter
- How to set selected attribute on option after filter query?
- Highlight search words in excerpt
- $_GET value is losing it’s space
- limit the number of searches
- Search For Custom Post Type and Custom Fields
- How can I prevent the Search Results Page from changing title?
- Problem with site’s search results “Read More” link?
- Dropdown switching subcategories portfolio
- Searching on my blog is not working
- WP search in metadata post
- “Modular/reusable” content and search results
- Custom Search Template for Custom Post Types
- Search doesn’t work with ‘relation’ => ‘OR’
- Add meta tag to search results
- Searchform for searching specific categories
- Search box background on a different page template
- Selectbox and Searchform and Custom Search Page
- SQL: Search query to get attachments only of those parents which are published
- Taxonomy search filters
- Change the text “search result for” on search result page
- Search redirects to index
- Want to creat a search for my wordpress theme [closed]
- Return 404 for /search/ queries – For Genesis
- Deprecating WordPress URL from Google, promoting custom domain [closed]
- Search with multiple selects that include tags
- Search results from a specific database table