You can run the same loop multiple times by using rewind_posts()
to output each type separately.
if( have_posts() ){
$types = array('post', 'lesson', 'series');
foreach( $types as $type ){
echo 'your container opens here for ' . $type;
while( have_posts() ){
the_post();
if( $type == get_post_type() ){
get_template_part('content', $type);
}
}
rewind_posts();
echo 'your container closes here for ' . $type;
}
}
Related Posts:
- WordPress post sorting with AJAX
- Alphabetical sorting of custom post type – one letter per page
- Group search results by post type, but hide post types with no results
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Custom post type, organized by categories
- What to and how to proceed with CPT to make DB small and efficient?
- Pagination Error : Duplicate argument being outputted
- Custom loop request based on custom field
- post_type incorrect for custom post type
- sorting in wp query based on custom field value
- WordPress search results grouped by post type
- Group search results by post type, but having a unique heading for each section?
- A to Z List of Custom Post Type in three columns
- Including metaboxes from custom post types in global search — continued
- Custom post type not showing in search result
- What’s the WP way to load remaining custom posts?
- WooCommerce sort products by the actual product width(not the shipping width)
- WP Query with categories only shows one post and ignores the category
- Pretty URL for custom search for custom post type
- Sort and filter custom post type posts by custom taxonomy
- Add post location with mile radius allowing search
- Post ID randomly printing on page
- A custom post within a custom post
- Include custom post type content in search
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- Get post count for search result based on post type
- Displaying Custom Posts on a Page
- Shortcode not working with post counter
- WordPress posts page for customer filtering and sorting along with category filter
- Problem: wp_query outputs all images on site
- Auto Complete Search
- manage_edit-{post_type}_sortable_columns sorts, but wrong!
- search suggest – filter post type
- Sort entries by date mixing two post types
- Searching Custom Post Types
- Get custom post type’s fields in a while loop as variables
- Custom Post Type within the Loop on Homepage (Page Template)
- The loop seems stuck to a single (now deleted) post
- Posts per row on archive page (custom post type)
- Order a custom post type admin screen by a second custom post type title
- How do i search authors from search form using author’s name
- How do I know the ‘meta_key’ for ordering my custom post type
- Remotely search WordPress sites using xml-rpc
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- BBPress Search results in WordPress search
- Limit Search to Post Type With Apostrophe return search not found
- Search filter triggered & sort by custom post type
- Set Custom Post Type in Widget Settings for use in Widget
- Custom post type conditional in loop
- Displaying and searching Custom Posts
- Search by tag name and category
- Listing all term items alphabetically / sorting loop
- Searching Custom Fields
- Advanced search form with filters for custom taxonomies
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Display related custom taxonomy posts in sidebar
- filter search custom field query
- Different results between permalink and query var search
- How to let users choose where to search for posts?
- WordPress Custom Search by post_type
- Include custom taxonomy term in search
- pagination not working for category.php (custom post types in categories)
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- How do I control the output of a custom post type in the loop?
- Display custom post type posts first, then default posts
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Targeting custom post type
- Does WP have a global of $id?
- How to sort posts in a custom post type by title in ascending order by default?
- WordPress Loop if/else
- get_the_title() is returning results from previous loop
- Custom Post Loop pulling all custom posts, not just one
- Conditional for a Single Post That Belongs to a Category?
- What content types are shown at a search page?
- Wrapping x posts in html without leaving empty html
- Can NOT search my custom post type?
- WP Query post__in not returning correct results
- Custom Post Type single.php template only shows the latest post
- Sort posts in loop by the WooCommerce Membership of the author
- Search one custom post type ONLY, disable “all posts”
- Including all post id’s of a custom post type into an array
- How to include custom post type posts on a page?
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Tag page only display 10 posts
- sort post types by amount of views
- Custom post_type search pages
- How can I group posts by months and years?
- get_post_type is always post
- Multiple Custom Post Type queries, how to DRY it up
- Custon Content within WordPress Loop
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- WordPress search and date filter not working with custom post type
- Bootstrap accordion looping through posts incorrectly
- Custom post type sorting: alphabetical order
- Main query not querying any posts in custom taxonomy template
- Custom Empty Results page for my Custom Post Type