Search code examples
phpwordpress

Wordpress posts loop pagination - first page return 125 posts instead of 10 and the rest return 10


I'm trying to show 10 posts per page with pagination on WordPress and the first page return 125 posts instead of 10 and the rest of the pages return 10 posts as requested, please assist :)

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$output = array();
global $post;
$args = array('nopaging' => false, 'paged' => $paged, 'posts_per_page' => 10, 'post_type' => 'post', 'order'=> 'DES', 'orderby' => 'date');
$postslist = new WP_Query( $args );

    if ( $postslist->have_posts() ) :
        while ( $postslist->have_posts() ) : $postslist->the_post(); 

    array_push($output, array("timestamp" => get_the_date('U'),"img_url" => get_the_post_thumbnail_url(), "title" => get_the_title(), "text" => get_the_content()));
         endwhile;  

        wp_reset_postdata();
    endif;

Solution

  • The sticky posts was the problem, I have excluded the sticky_posts from the query, and it fixed the problem

    'ignore_sticky_posts' => 1