According to this answer of yours, you can do the following inside your search.php:
if (isset($_GET['post_type']))
get_template_part('search', $_GET['post_type']);
else
// no post_type given
Then you have to set up the search-{post_type}.php files.
If you want to handle only some of the existing post types differently, do this by means of a switch:
$type = (isset($_GET['post_type'])) ? $_GET['post_type'] : '';
switch ($type) {
case 'attorney':
case 'criminal':
case 'musician':
get_template_part('search', $type);
break;
default:
// default search stuff
}
Related Posts:
- Advanced search form with filters for custom taxonomies and custom fields
- Search multiple custom fields by using meta_query
- How do I Paginate Search Results for Custom Post Types?
- WordPress post sorting with AJAX
- Why have my custom post type searches stopped working after changing URLs / updating WordPress?
- Have different search results template depending of custom post type searched
- Exclude a term of a taxonomy with a custom post type in a search
- Include images from pages in wp search.php results in default wp search
- Separating Search Results By Post Type
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Custom Post Types: pretty search URLs and has_archive
- 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
- Group search results by post type, but hide post types with no results
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- 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
- 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?
- Search one custom post type ONLY, disable “all posts”
- 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
- Redirecting search to specific templates with $_GET[“post_type”]
- 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
- post_type incorrect for custom post type
- Live search by custom tag
- Custom search for a custom post type in WordPress
- how to create custom taxonomy drop downs for parents and child
- 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
- Extensive search filtering and results->PDF in the front-end
- 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
- Advanced search form with filters for custom taxonomies and custom fields
- Problem with custom post type search
- 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
- 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
- How can I retain get_post_type() in between consecutive searches after a search returns no results?
- How do I create a custom search function to only show contact information if they search for an exact unique identifier?