Different number of posts showing in development vs production server

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:

      ?php
        $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
          /a
        /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?

Topic wp-reset-query loop wp-query Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.