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?
- How to create a custom search for custom post type?
- Extending the search context in the admin list post screen
- Development of a WordPress Search Plugin – Best Practices
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Custom Post Type, WP_Query and ‘orderby’
- Get Custom post with ID
- WP_Query to loop a Custom Field, Custom Post Types do not show
- filter search result with custom post type meta key
- Posts in Multiple Columns and Rows with one single loop
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- sort events based on event date custom field
- Get_post_meta() won’t return value
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- ‘category__and’ for custom taxonomy?
- multiple search forms and search results
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Custom-post-type-archive: posts sorted/filtered by year?
- Custom Fields vs Separate Table
- get_template_part for custom post type content not working
- How to insert content from another Custom Post type into Post?
- Display different content on homepage depending on post type
- WP_Query orderby modified to include custom meta changes
- get_attached_media() on author page not working
- Calculate all custom field values in the post loop
- Multiple meta_values in the pre_get_posts filter?
- How to order separated Custom Post Search results
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Custom post type search using $_SESSION and pre_get_posts
- List custom taxonomy specific to one custom post type
- Make parts of your wordpress website completely built with data from external APIs?
- A custom post within a custom post
- Auto Complete Search
- Remotely search WordPress sites using xml-rpc
- Limit Search to Post Type With Apostrophe return search not found
- Search by tag name and category
- WordPress Custom Search by post_type
- get_the_title() is returning results from previous loop
- How can I group posts by months and years?
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- 3 random images from custom post type, each in a div with a diffrent class
- Displaying multiple post types on home page
- Shortcode leaves no space for other elements?
- search custom post type by custom fields on front end
- Query to get child pages of current page and display it in action hook
- Custom Search | check multiple meta_value for search value
- Get post format
- Make a custom column sortable by a value from a different custom post type
- Display post from custom post type
- WordPress giving a 404 page when passing a year argument different than the current year
- Blank search results on custom search
- Add Class according to the order of appearance
- Permalinks for single-[custom-post-types] not working
- Drop down list with posts within the “add new” page
- How to show custom post type on homepage and in categories
- using the loop in custom meta is messing up ‘add new’ post type
- How can I sort the order of multiple custom field values in a custom post type?
- Sorting the Loop by Taxonomy Value
- Custom archive page for custom taxonomy and pagination issue
- Update query based on CPT / Post Type, show all sorted by date
- How to avoid duplicate posts queried from custom meta?
- Looping to organize and display custom posts by category using PHP and WordPress
- Pagination for a cpt filtered with a category
- How to use multiple orderby conditions on query search results? (orderby one post type, relevance)
- My post loop needs to have 8 different post templates
- Mix Facebook and Twitter feed into custom posts
- week days sorting based on starting day
- Infinite scroll doesnt work
- Excluding category from loop not working
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- Strange behavior on WP_query
- Ordering Posts List By Taxonomy Terms?
- How to check if meta box value is false for all posts then do something based on that
- Custom taxonomy page template
- Trying to modify custom search function in plugin to search postmeta table for keyword as well as posts table
- Display posts from category in page
- Custom post type blog pagination conflict
- Multiple Queries and Loops within CPT Archive
- Make custom post type column sortable
- Pagination not working with custom loop
- Display multiple custom post type lists on homepage – multiple loops
- Query Custom Post Type by Tag
- Loops running into each other
- Display by tag from different post types
- Loop doesn’t work in single-product.php page but works at normal page
- Test if a Category contains certain Custom Post Types
- Custom Field Search