I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query:
$query = new WP_Query( array (
'posts_per_page' => 15,
'post_type' => array ( 'cpt1', 'cpt2', 'cpt3', 'cpt4', 'cpt5' )
)
);
It works fine, shows latest 15 posts from these 5 custom post types. But problem is, there are too many updates on cpt1 and cpt3 (around 8-10 posts per day on each post type). So on home page, I rarely find posts from cpt2/4/5.
So I want to show latest 3 posts from each post type (total 15 posts) using date as order by (sorting). So 3 posts from each post type will be visible and sorted based on date among all 5 post types. But I could not find any good solution for this.
What came so far in my mind is, running 5 queries and saving them to an array, and then sort them.
Is there anyway I can do this using only one query, instead of 5 queries?