我使用get_posts来抓取4个不同类别的多个帖子。
$blog_args = array(
'posts_per_page' => 12,
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array( array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => '',
), ),
);
$blogs = array();
foreach ($cat_slugs as $slug)
{
$blogs_args['tax_query']['terms'] = $slug;
$blogs[$slug] = get_posts($blogs_args);
}
我想要的是,我想从每个类别和日期desc获得一个帖子。如,
[Post1 From Cat1, Post1 from Cat2, Post1 from Cat3, Post1 from Cat4, Post2 from Cat1, Post2 from Cat2, Post2 from Cat3, Post2 from Cat4, ...]
是否有查询来获取此类数据?我能找到的唯一方法是获取每个类别的所有帖子(4个不同的查询)并逐个合并,这是一个性能问题。
提前谢谢你,