There are several ways to do this. Here’s an easy one. Let’s say you want to mix 9 ‘daily’ posts and 3 ‘quotes’. First you would have to get those posts:
$dailies = get_posts(array('posts_per_page' => 9, 'post_type' => 'daily'))
$quotes = get_posts(array('posts_per_page' => 3, 'post_type' => 'quote'))
Next you would loop through them like this:
for ($i = 0; $i <= 9; $i++) {
// html to output $dailies[$i]
$j = (($i-2)/3) // will be integer if $i=2, 5, 7, so after three dailies
if (is_int($j) {
// html to output $quotes[$j]
}
}
You will need to add some extra logic to prevent errors in case there are less than 9 or 3 posts respectively.
Related Posts:
- Query multiple custom post types in single loop
- Inject post (from specific category) between posts in Loop
- Build a content and excerpt grid loop with paging and options for # of posts
- Alter secondary loop to exclude posts from current page category
- Specific Loop For 2 Within Each
- How to change post count in wordpress loop?
- Count number of published posts by type
- How to get to a specific position in wp_query?
- have_posts() execution failure
- How to make sure content doesn’t display if selection is empty
- Using foreach loop breaks
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- WP_Query fails despite having 1 post
- wp_query get the 2nd post
- How to get post ID in a Page?
- Display an image if odd number of posts in grid
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- get_the_ID() in the footer returns wrong value
- Get all posts as an array ID => Name
- WP_Query multiple post results
- Do not duplicate posts with multiple categories in multiple loops
- Infinite Loop – WP_Query
- Dividing the loop to style post differently
- How to extract information from a wp_query result?
- Search.php gets metadata from first post
- the_post(); prints out style text into my HTML?
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- Wp Query : Order by distance lat,lon
- in_array not working on dev server but works on localhost
- How to display sticky post always at the top (before regular post) in wordpress?
- Making list of posts with chosen description
- My query keeps looping infinitely ! how to stop it?
- Efficient way of querying for a “fallback” post?
- Add post class in custom loop (WP_QUERY)
- Create a hierarchical loop at predefined markup requirements
- WP_Query count of different meta key values [duplicate]
- divide custom field values in div every two values
- Advanced Taxonomy query, with 3 post types
- Why does a meta_query break this WP_Query?
- WordPress post pagination on custom template not working
- Pagination in category.php not functioning
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Count the number of matching post names in foreach loop
- How do I exclude the current post from the upcoming post query
- How do I display WooCommerce products in my query to rows of 3?
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress
- How to show correct td of table tags in wp_query loop
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Cannot display or echo alt text on featured image
- Using Advanced Custom Fields to create a per page slider
- Split loop into two columns, how to favor one side over the other
- WordPress Search Results for Multiple Post Types
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- wp_query with cat not working
- Changing layout with wp_customise
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- How to use an associative array in post__in with WP_Query?
- Dynamic Stylesheet loads but doesn’t finish
- Filter Select results based on selection
- User’s total comment count excluding comments on their own posts
- If Query In Sidebar
- Using loop pagination on single.php
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Loop with slider (slider not loading)
- Compare post-IDs within WP_Query? (Less than / Greater than)
- How to hide all child pages with post_query?
- How to sort posts based on the value (number) of a post’s metadata?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- How to use $query->set with post__in?
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Loading the same WP_Query in two different wordpress .php templates
- How to prevent WP_Query function from returning all posts when empty?
- Dynamic content based on a URL parameter
- Display a specific category of products in shop page and disable code for specific actions
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Iterate through posts based on array of categories
- get author_name from queried post
- Displaying Woocommerce Product Category in WordPress
- Add more button if more 8 items
- How to store post ID’s in cookie or session to display the same posts later
- How can I add extra word in permalink when someone click download button?
- WordPress, AJAX and pre_get_posts using conditional tags
- Increase offset while looping
- Get users that likes the post
- Blog posts repeat
- How to add condition in wordpress loop? [closed]
- Woocommerce : Can’t get product info in loop
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Exclude posts based on meta value
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Custom query, checking values of multiple meta keys