Use pre_get_posts to filter search results:
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('post_type', 'custom_post_type_name');
$query->set('cat', intval($_POST['cat']); // assuming you have a select with categories with name "cat"
}
}
}
add_action('pre_get_posts','search_filter');
Related Posts:
- Include custom taxonomy term in search
- Advanced search form with filters for custom taxonomies and custom fields
- How to replicate some of Drupal Views functionality in WordPress?
- Exclude from search all custom posts which are NOT in a taxonomy term
- Exclude a term of a taxonomy with a custom post type in a search
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Custom search for custom post type, custom meta and search fields
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- How to search from specific post type with tags?
- Include different loop templates in search query
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- CPT Search Form with Taxonomy filter & Or
- Keyword search limited to specific post type filtered by multiple custom taxonomies?
- How to create an advanced filter search?
- Search Custom Post Type & Taxonomies
- search also in taxonomy, tags and custom fields
- WordPress sort search results by custom order
- Pretty URL for custom search for custom post type
- Auto Complete Search
- 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
- Include custom taxonomy term in search
- how to get this tax_query working?
- Custom Taxonomy Search result page
- 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
- Hide custom post type from search based on custom taxonomy
- Ideas on how to organize a project [closed]
- Multi Parameter search with custom post type category and tag
- How to Implement Search Functionality?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Live search by custom tag
- Custom search for a custom post type in WordPress
- Extensive search filtering and results->PDF in the front-end
- Advanced search form with filters for custom taxonomies and custom fields
- Archive custom template from search
- Saving Taxonomy Terms
- Get Posts by Custom Post Type ,Taxonomy, and Term
- How do I Paginate Search Results for Custom Post Types?
- Limit the number of posts in query_posts function with custom post types
- Taxonomy archive with same slug as custom post type?
- Find callback function for custom taxonomy metabox
- Need some templating advice for templating with custom post types and taxonomies
- If on term-page -> get the current term?
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Custom Post Types: pretty search URLs and has_archive
- Filter posts with ajax form and checkboxes
- Should I change these content meta types before building complex archive page?
- custom post type paging not working past page 3
- get terms that have post with custom post type between 2 values
- How to show custom taxonomy in the permalink?
- Working with Next and Prev links in Single Taxonomy Templates
- Custom Post Type not appearing in website search
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- get_posts of Custom Post Type AND Custom Taxonomy
- Get posts by querying taxonomy and certain terms of the taxonomy?
- How to add a custom taxonomy to show up in a custom post type menu?
- Query Custom posts of same taxonomy as the post itself
- How to change permalink to include custom post type
- Taxonomy/Custom post type structure suggestion on a movie site
- Listing all term items alphabetically / sorting loop
- Change the Custom Taxonomy URL Slug pattern
- Losing Nav Active State in Menu
- How to make WP_Query not to show irrelevant posts?
- Custom select query for taxonomies that have posts categorized in another taxonomy
- How to list tags from custom post type attachments?
- Implementing Pillar Posts; Long Posts yet with Some Page-Like Handling?
- Dynamically insert code to custom post type loop
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- Custom taxonomy template list not working (404)
- Link From Single Post To Taxonomy Term Archive Page
- Print all the tags from a custom post type
- How to organize custom post type list by year?
- does wp_insert_term link the term to a certain post ID?
- Calling related posts to a custom post type, taxonomy & Tag id
- Custom post type category permalinks and archive pages
- Better in the long run to use post date or custom taxonomy to sort/separate posts by year?
- add_filter get array data before display in custom post_type
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Define multiple prefixes for custom post type
- Remove custom taxonamy slug with pagination
- Order archive custom posts by taxonomy term [duplicate]
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Problem displaying posts for a category in a custom taxonomy
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Custom taxonomy- only output relevant terms
- Post types showing tables…Can I do that?
- Dropdown switching subcategories portfolio
- How to solve performance issue caused by custom post type overview with 20k+ custom taxonomy terms
- 404 error Custom search results page for custom post types with friendly URL
- Prevent repetitive terms in get_the_term_list
- Displaying posts exclusively in their category (not parent)
- Show taxonomies from specific CPT
- Category / Custom Post Type permalink issue
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Advise on Custom Taxonomies and Structure