WP_Query pulling an extra post per page

Sticky posts do add to the post count rather than being included in it. You can alter your query to ignore sticky posts though.

$allposts = array( 
    'post_type'           =>  'post',
    'posts_per_page'      =>  20,
    'ignore_sticky_posts' => true
);

But you are also missing pagination parameters.

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$allposts = array( 
    'post_type'           =>  'post',
    'posts_per_page'      =>  20,
    'ignore_sticky_posts' => true,
    'paged'               => $paged
);

Leave a Comment