Title: Loop for posts isn&#039;t working correctly
Last modified: August 20, 2016

---

# Loop for posts isn't working correctly

 *  [dzupec](https://wordpress.org/support/users/dzupec/)
 * (@dzupec)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/loop-for-posts-isnt-working-correctly/)
 * I can’t figure out whats wrong with this code. I want it to show 10 blog posts
   on a page-which it does, but when you click on the “older post” link at the bottom
   it just re-hashes the same 10 blog posts instead of showing more of the older
   ones. Thank you all, your help is appreciated : )
 * _[code moderated - please follow the [forum rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code)]_

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/loop-for-posts-isnt-working-correctly/#post-2478075)
 * You must include the ‘paged’ argument to query_posts() to get pagination. Try
   changing this:
 *     ```
       <?php query_posts("posts_per_page=10"); ?>
       ```
   
 * to this:
 *     ```
       <?php
       $paged = (intval(get_query_var('paged'))) ? get_query_var('paged') : 1;
       query_posts("posts_per_page=10&paged=$paged"); ?>
       ```
   
 *  Thread Starter [dzupec](https://wordpress.org/support/users/dzupec/)
 * (@dzupec)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/loop-for-posts-isnt-working-correctly/#post-2478152)
 * Hey vtxyzzy,
 * Thank you so much this worked : ) Could you explain to me or show me where I 
   can find the explanation for this? I just never had to add this before to get
   it to work.
 * Thank you!
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/loop-for-posts-isnt-working-correctly/#post-2478170)
 * When you click on a ‘Older posts’ link, it creates a URL like this if you are
   using pretty permalinks: `http://yoursite.com/page/2`
 * The ‘/page/2’ part is the way that the page number is passed to the next query.
   In order for that query to actually use the page number, the ‘paged’ argument
   needs to be included. You get the value of the page from the URL using get_query_var().
 *  Thread Starter [dzupec](https://wordpress.org/support/users/dzupec/)
 * (@dzupec)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/loop-for-posts-isnt-working-correctly/#post-2478255)
 * Thank you for explaining that too me : )

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

The topic ‘Loop for posts isn't working correctly’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [dzupec](https://wordpress.org/support/users/dzupec/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/loop-for-posts-isnt-working-correctly/#post-2478255)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
