Title: query_posts and pagination problem
Last modified: August 19, 2016

---

# query_posts and pagination problem

 *  [Daniel Tara](https://wordpress.org/support/users/pseudoxiah/)
 * (@pseudoxiah)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/query_posts-and-pagination-problem/)
 * Hi.
 * I am developing a magazine style theme for WordPress. I want to display the latest
   3 posts on the front page and on the upcoming pages the default number of posts.
 * The problem is, it is displaying the first 3 posts on the front page and then
   on the next page it displays posts 11 to 20 or a 404 error if there are less 
   then 11 posts published.
 * Here’s the code I’m using:
 *     ```
       <?php if(!is_paged()) { ?>
         <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
           query_posts("paged=$page&posts_per_page=3"); ?>
         // The_Loop
       <?php } ?>
       <?php else { ?>
         <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
           query_posts("paged=$page"); ?>
         // The_Loop
       <?php } ?>
       ```
   
 * So technically posts 4 to 10 are never displayed. Besides from that, the last
   page always displays a 404 error, although the link to it is displayed.
 * Any ideas what i’m doing wrong?

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/query_posts-and-pagination-problem/#post-1218747)
 * If you can stand 13 posts on the first page, and 10 on the rest, could just use
   a [get_posts()](http://codex.wordpress.org/Template_Tags/get_posts) loop for 
   the first 3 posts and let the ‘normal’ loop display the remaining 10 posts and
   then let next_posts_link/previous_posts_link handle the rest.
 * But, also wonder if [Scott Reilly’s Inject Query Posts plugin](http://coffee2code.com/archives/2009/04/18/inject-query-posts-v10-new/)
   might be useful…haven’t tried it but something to consider.

Viewing 1 replies (of 1 total)

The topic ‘query_posts and pagination problem’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/query_posts-and-pagination-problem/#post-1218747)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
