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
- Store loop into array
- Looping through WP_Post Object
- Display Post co-authored in Author Page
- Show Custom Taxonomy Title
- How to exclude specific category from the get_the_category(); array
- Sorting Posts | Alphabetical Order
- spliting posts into two columns
- How to Display a Single Post Excerpt
- Changing layout with wp_customise
- How to use an associative array in post__in with WP_Query?
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- get author_name from queried post
- WordPress, AJAX and pre_get_posts using conditional tags
- Exclude posts based on meta value
- Remove echo from shortcode
- post thumbnail, conditions, else wont work
- unable to use ‘new WP_Query’ in AJAX call
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Why in my theme I can’t see all the statics content under the posts?
- How to unlink all posts from tracking same amount of views
- How to hide posts of a specific custom category in WordPress?
- Problem with custom loop and wp_list_pluck [closed]
- WordPress WP_Query without query GET parameters
- First post article different on Archives template
- How to add title attribute to archive items
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Nested Queries of decreasing specificity
- Wrong pagination results, page counter resets when navigating
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- How to Create Carousel Indicators in PHP Loop using wp_get_attachment_url function?
- WP query posts BUT show the most recent and one per author
- Get title of page containing post grid within the posts
- Define global custom post
- Is there anyway I can call the year once?
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- cURL needing to loop through all “next_page”
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- Search for single post by 2 tags
- Show the subcategory name based on current product
- How can I get my pagination loop to display the correct number of total pages?
- Woocommerce Related Product by 2 taxonomy
- Get current_post in reverse order with pagination
- Loop 1 user randomly
- enumerating custom taxonomies?
- Query seems to be duplicated
- How to display thumbnail if post is assigned one otherwise not
- Remove the_content From Loop
- Adding if statement to content for homepage
- Tables not showing divs and loop/php items
- Keeping the previous get value and add another value when submitted
- How to create a loop that will display one post and stop?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- How to sort search result by post_title, then by post_content