I would recommend using content-{posttype}.php method, where you only have HTML markup, template tags for posts or custom post types and leave loops outside of those files. See Twenty Eleven for more detailed example.
After this change you can easily modify search.php and include specific content markup based on post type.
if ( have_posts() ) :
while ( have_posts() ) : the_post();
/**
* Would include CPT content template (content-teams.php) if it exists
* or content.php otherwise.
*/
get_template_part( 'content', get_post_type( $post ) );
endwhile;
endif;
Related Posts:
- Include custom taxonomy term in search
- Advanced search form with filters for custom taxonomies and custom fields
- Searching multiple custom post types and pages
- Taxonomy, Terms, and Template Files
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- Get page by template?
- How to replicate some of Drupal Views functionality in WordPress?
- Custom taxonomy query for a custom post type
- 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
- Need some templating advice for templating with custom post types and taxonomies
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Custom Post Type with Nested Taxonomy and Template Files
- Custom Post Type Archive Template
- Custom search for custom post type, custom meta and search fields
- Querying Posts by Taxonomy From Alternate Network Site
- Custom Search | Wrong output & question
- custom post type archive template per custom taxonomy term
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- custom taxonomy – Template not working
- Create separate template for shared custom taxonomy with shared terms
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- How do I provide a “show all posts” link in a paginated term archive?
- WP_Query search posts by custom post type and custom taxonomy
- CPT Search Form with Taxonomy filter & Or
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Keyword search limited to specific post type filtered by multiple custom taxonomies?
- How to filter custom taxonomy categories on archive?
- Querying Term Posts in Loop
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Get next and previous 3 posts in a term in single post page
- Search Custom Post Type & Taxonomies
- Making certain categories of CPT not publicly queryable
- Query with no terms uses index.php template instead of archive.php
- Get parse_query filter to return slug instead of id
- Create template for taxonomy results limited by Custom Post Type
- How do I move/order posts with a tag to the end?
- WordPress sort search results by custom order
- Specific query for custom post type
- Pretty URL for custom search for custom post type
- WordPress Doesn’t Generate Taxonomy Archive
- Display post content with respect to its title?
- First custom field value (out of several) displayed twice after query
- WP_Query orderby and tax_query
- Migrating a taxonomy’s tags to the native category
- Advanced search form with filters for custom taxonomies
- WordPress custom taxonomy template not working
- How can I get this request to use the Custom Post Type page template instead?
- Include custom taxonomy term in search
- Archive for a Taxonomy of a Custom Post type
- Custom post_type search pages
- Main query not querying any posts in custom taxonomy template
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- WP_Query() with custom post type and taxonomy — get all terms?
- Can I query posts by taxonomy conditionally based on post type?
- Which file/template is in charge of taxonomies for custom post types?
- how to get this tax_query working?
- Custom Taxonomy Search result page
- How to get_term_meta on single custom post?
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Query not work for current taxonomy
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- Hide custom post type from search based on custom taxonomy
- Custom Post Type setup
- Pagination on search results page
- Ideas on how to organize a project [closed]
- Filtering custom posts by custom fields (ACF) [closed]
- Multi Parameter search with custom post type category and tag
- Custom types, taxonomies and query optimization
- Create a custom taxonomy template that loops through child categories in term order?
- Query custom posts from custom taxonomy
- How to Implement Search Functionality?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- How to divide Subcategories into pages of parent category wordpress
- Change search query in wordpress custom post type
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Post template with breadcrumb needs to show page navigated from
- Displaying all posts by category and showing content on click
- Creating a custom WP query for a Custom Post Type
- Custom Post Taxonomy Template Not Loading Properly
- Live search by custom tag
- Custom taxonomy with custom post type template not showing
- Custom taxonomy template for custom fields loop [closed]
- Single taxonomy for different custom post types
- How should i name the .php file to show custom posts under a taxonomy’s term?
- I want to create an archive and single page for a custom taxonomy for a custom post type
- Get posts of an specific term of a custom taxonomy
- Conditional posts in WP_query for search
- Custom Post Type tag taxonomy “Page Not Found”
- Query Pulling the same post twice
- template structure for CPT not clear
- Extensive search filtering and results->PDF in the front-end
- Search page for custom post type
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Advanced search form with filters for custom taxonomies and custom fields
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Archive custom template from search
- WordPress search results
- Most appropriate way to display CPT’s by children terms of custom taxonomies while retaining desired permalink structure?
- Only One Post of Custom Post Type Appearing on Template Page