I’m looking to create a site wide feed on my site and have multiple custom post types. I’d like to display say 3 posts from at least 3 different post types. I can get the latest 10 posts across each post type, and I can get the latest 10 overall, but I’d like to specify so that I only get 3 from each so things are even. Is the best way to do it do 3 different queries and then merge them? I get how to do this separately, but I want them all integrated and sorted by timestamp. Any suggestions?
Leave a Reply
You must be logged in to post a comment.
This method uses a counter and 1 query. Only 3 posts from each post type can ever be displayed.
This might not be the best solution if you have a really large amount of posts because it will loop through all the posts and if the count is higher than 3 for the given post type it will go back to the beginning of the loop.