WP_Query posts_per_page不适用于第1页

时间:2019-05-07 15:29:12

标签: wordpress

我仅在第1页上有WP_Query的问题

$query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 12, 'paged' => 1));

它返回181个结果

但是,如果我这样做:

$query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => 12, 'paged' => 2));

它返回12个精确结果。

181个帖子而不是我的帖子总数

enter image description here

也许贴子有问题吗?

1 个答案:

答案 0 :(得分:0)

由粘帖引起的问题。添加此参数可以正常工作:

$args['post__in']            = get_option('sticky_posts');
$args['ignore_sticky_posts'] = 1;
相关问题