Pagination – Same list of posts in every page issue !

As per Wikipedia, Pagination is the sequence of numbers assigned to pages in a book or periodical.

In WordPress, we generally use WP_Query or query_posts to fetch posts and display the list with pagination. A simple query would look like this:

<?php query_posts('posts_per_page=3'); ?>

This will work just fine in most of the cases but sometimes we hear issues that the pagination is not working properly or pagination numbers are correct but every page shows the same list. It’s mostly because we haven’t included the ‘paged‘ parameter to the query. The following is taken from WordPress Codex.

you add the parameter like this:

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

query_posts('posts_per_page=3&paged=' . $paged); 
?>

The next example is exactly the same as above but with the parameters in an array:

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
  'posts_per_page' => 3,
  'paged' => $paged
);

query_posts($args); 
?>

Detailed information about how to properly configure and work with WordPress Pagination can be found in the WordPress Codex.