So I'm working on a website for a client. Everything works fine except for the fact that the number of posts showing in the homepage of my development server is different from the number of posts showing in the production server.

Here's my query:

        $args = array( 'post_type' => 'post', 'posts_per_page' => 4 );
        $loop = new WP_Query( $args );
        while ( $loop->have_posts() ) : $loop->the_post();
        <div class="mini-post col-xs-12 col-md-6 col-lg-6">
          <a href="<?php the_permalink(); ?>">
            <h3><?php $title = the_title('','',false); echo wp_trim_words( $title, 8, null ); ?></h3>
            <p class="date"><?php the_time( 'F j, Y' ); ?></p>
        </div> <!-- .mini-post -->
      <?php endwhile; wp_reset_query(); ?>

As you can see, I'm limiting the number of posts to 4. And it works here

However, in my live website, it's showing 6!

I've tried writing the query in different ways and still get the same result.

Any ideas what could be wrong?

  • 2
    If something is overriding your query arguments, you have a filter somewhere modifying the query.
    – Milo
    Commented Nov 15, 2014 at 16:11
  • 2
    Are any of the posts sticky? See: wordpress.stackexchange.com/a/99697/21376
    – s_ha_dum
    Commented Nov 15, 2014 at 18:54
  • @s_ha_dum had the correct answer. I had some sticky posts messing up my post count.
    – Johann
    Commented Nov 18, 2014 at 18:30

1 Answer 1


As noted by @s_ha_dum, I had some sticky posts. I had to use the

'ignore_sticky_posts' => true 

argument inside the WP_Query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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