这在一个查询中是不可能的。不能为单个分类查询设置每页的帖子。
您可以同时查询12个状态或搁置帖子:
array(
\'posts_per_page\' => 12,
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => array( \'post-format-status\', \'post-format-aside\' ),
),
),
)
或使用执行单独的查询
get_posts()
使用每个结果所需的数字,合并结果,然后按日期对合并结果进行排序:
// Get statuses.
$statuses = get_posts( array(
\'numberposts\' => 7,
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => \'post-format-status\',
),
),
) );
// Get asides.
$asides = get_posts( array(
\'numberposts\' => 5,
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => \'post-format-aside\',
),
),
) );
// Merge results.
$posts = array_merge( $statuses, $asides );
// Sort results by comparing the dates.
uasort( $posts, function( $a, $b ) {
return strtotime( $b->post_date ) - strtotime( $a->post_date );
} );
global $post;
foreach ( $posts as $post ) : setup_postdata( $post );
endforeach; wp_reset_postdata();