I have 3 posts types, articles
, news
and tips
. On the home page I want to query 20 posts in this order:
article, article, news, news, tip, ...// same order again until 20
If I use a custom query like so:
$query = new WP_Query(array(
'post_type' => array('articles', 'news', 'tips'),
'posts_per_page' => 20,
));
I get 20 items but how to order them? Would it be possible to make 3 different queries and then merge the results?
You definitely could use three different queries and then merge them.
This may look like a very odd way to do this, but this way you can use the loop and preserve the option to use pagination. Although a direct query to the database can be quicker I guess.
You could try a modified version of this answer :
where
So the posts are first ordered by
post_type
(asc) and then bypost_date
(desc).