WordPress:如何为每个自定义帖子显示两个帖子


Wordpress: how to show two posts per custom post?

我有一些自定义帖子类型。我想循环浏览其中的三个,每种帖子类型只显示两个帖子!

以下代码有效,它得到我想要的帖子,但是如果"幽默"中有 4 个帖子,"犯罪"中有 2+ 个帖子,则查询永远不会到达"浪漫"帖子

$args = array( 'post_type' => array('humour', 'crime', 'romance'), 'showposts' => 6);
$query = new WP_Query( $args );

我确实考虑过创建三个不同的新查询(使用 WP_Query ),但我有一种感觉,这将是矫枉过正!有没有其他方法可以做到这一点?

试试这个

"numberposts" => 2,