Title: Loop: pagination doesn&#039;t work
Last modified: August 20, 2016

---

# Loop: pagination doesn't work

 *  Resolved [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * (@lorenzone92)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-pagination-doesnt-work/)
 * What’s wrong with this code?
    [http://pastebin.com/Cv7yDsNv](http://pastebin.com/Cv7yDsNv)
 * Why if I click on “Next page” I go to /page/2/ but the same posts of page 1 are
   displayed? If I click on “next page” on /page/2/ I go to /page/3/ but still the
   same posts are shown (and so on)..

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-pagination-doesnt-work/#post-3266634)
 * This is your problem.
 * `query_posts( 'cat=1&posts_per_page=2' );`
 * More info:
    [http://codex.wordpress.org/Function_Reference/query_posts#Pagination](http://codex.wordpress.org/Function_Reference/query_posts#Pagination)
 *  Thread Starter [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * (@lorenzone92)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-pagination-doesnt-work/#post-3266638)
 * Thanks, marked as solved.
    Out of curiosity, why on category.php pagination works
   without having the paged param?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-pagination-doesnt-work/#post-3266642)
 * Because you’re not doing a query_posts there?
 * The query_posts() function changes the main query for the page. When you use 
   it, you override the “automatic” main query which takes everything into account
   normally, and tell it that you want to do something other than the default.
 * Really, you should use the pre_get_posts filter instead of the query_posts() 
   function. Then you can modify the main query instead of overriding it entirely.
 *  Thread Starter [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * (@lorenzone92)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-pagination-doesnt-work/#post-3266643)
 * Thanks, I’ll read about pre_get_posts. Never heard of it before, always used 
   query_posts. Will have a look! 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Loop: pagination doesn't work’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [multiformeingegno](https://wordpress.org/support/users/lorenzone92/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/loop-pagination-doesnt-work/#post-3266643)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
