WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm querying to get a list of all posts, 20 posts_per_page, but the result shows all posts, but with 21 posts per page. If I change posts_per_page to 19, then 20 show. One post is sticky and shows up twice; not sure if that is causing the problem.


$allposts = array( 
    'post_type'         =>  'post',
    'posts_per_page'    =>  20

$wp_query = new WP_Query($allposts); ?>

<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<li><?php the_title(); ?></li>

<?php foo_pagination(); ?>

<?php endwhile; ?>
share|improve this question
up vote 5 down vote accepted

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
share|improve this answer
Accepted and upvoted. The ignore sticky posts did the trick. I have my pagination parameters in the pagination function that I call, but thanks for including them (for future googlers). It's also worth noting that ignore_sticky_posts doesn't keep the sticky posts off the list, it just treats them like other posts--they show up once. – chowwy Feb 13 '13 at 2:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.