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
- Templates for Custom Post Types and Custom Taxonomies
- 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
- SQL to update custom post taxonomies
- Query multiple taxonomy in Custom Post Type
- 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
- How to search from specific post type with tags?
- Create separate template for shared custom taxonomy with shared terms
- Trying to manage templates on a blog with lots of custom taxonomies
- 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?
- Show Two custom Post type and their posts on category page
- How to filter custom taxonomy categories on archive?
- How to create an advanced filter search?
- Querying Term Posts in Loop
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Am unable to reset a query properly
- 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
- Search / Filter posts on Title/Content OR Tags
- Query with no terms uses index.php template instead of archive.php
- Get parse_query filter to return slug instead of id
- search also in taxonomy, tags and custom fields
- Create template for taxonomy results limited by Custom Post Type
- Template for custom post with custom taxonomy
- How do I move/order posts with a tag to the end?
- WordPress sort search results by custom order
- Custom taxonomy and custom post type – wrong permalinks and template
- 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?
- Auto Complete Search
- Custom taxonomy returns 404
- 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
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Change search query in wordpress custom post type
- Check that a slug is present in the get_terms request
- 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
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Live search by custom tag
- Custom search for a custom post type in WordPress
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- taxonomy – templates are not loading
- Custom taxonomy with custom post type template not showing
- Custom taxonomy template for custom fields loop [closed]
- Templates for CPT not working
- 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
- WordPress Custom taxonomy template
- Extensive search filtering and results->PDF in the front-end
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Querying multiple taxonomies in URL leads to wrong taxonomy archive
- Search page for custom post type
- Query Only Show Text on Posts With Certain Taxonomy Tag
- how to limit query_post to first page?
- Advanced search form with filters for custom taxonomies and custom fields
- Listing custom post type items from a couple of custom taxonomies
- 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
- Custom Field Search
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Search for portfolio tags & mixing portfoliotags and post tags