Title: posts_per_page is wrong
Last modified: August 19, 2016

---

# posts_per_page is wrong

 *  [ambius](https://wordpress.org/support/users/ambius/)
 * (@ambius)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/)
 * I want to display only the 4 most recent posts.
 * I have accomplished this on a custom template page within my site by setting 
   query_posts(‘cat=5&posts_per_page=5’); I can change the posts_per_page to any
   number and the loop outputs the correct number of posts.
 * but in my index page, when I set query_posts(‘posts_per_page=4’); I get 5 posts.
   I’ve tried other limits with odd results: 1=4, 2=4, 3=5, 4=5, 5=6, 14=15. I suppose
   I could use a counter variable inside my php loop to force the exact number of
   posts that I want to see but I wanted to report this as a bug for WP staff to
   fix. I’m using the newest 2.9.2. I think the strangest part is that the limit
   works correctly on one page but not on index.
 * does anyone else or any other versions have this same problem?

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

 *  Thread Starter [ambius](https://wordpress.org/support/users/ambius/)
 * (@ambius)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468726)
 * I think figured out part of my problem. I have 4 sticky posts that I was using
   to stick at the top of a different page… I’m guessing that is why there is a 
   minimum of 4 posts returning. However, I still don’t know why I’m getting 5 when
   I ask for 4, or 15 when 14, etc. I have exactly 4 sticky posts in my entire database.
 *  Thread Starter [ambius](https://wordpress.org/support/users/ambius/)
 * (@ambius)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468733)
 * sorry for posting in my own topic, yet again, but I think I finally fixed my 
   problem and wanted to share the code in case it helps someone else.
 * I added caller_get_posts=1 to my query arguments to treat sticky posts like a
   normal post. This works great for me because I didn’t want any of those stickies
   to be sticky on my index (only on a few archive pages). Now when I tell it to
   give me 3 posts it gives exactly 3. and when I ask for 6 it gives me exactly 
   6.
 * However, **I still think WP is bugged because** when you allow stickies to be
   sticky, the posts per page count is off by 1. an easy programming mistake to 
   make.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468803)
 * > However, I still think WP is bugged because when you allow stickies to be sticky,
   > the posts per page count is off by 1. an easy programming mistake to make.
 * Not a bug–that’s the way the developers intended it to work.
 *  Thread Starter [ambius](https://wordpress.org/support/users/ambius/)
 * (@ambius)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468902)
 * either we are not understanding each other here, or your developers have a pretty
   flawed idea of how to implement features with consistency. Not exactly logical
   for 5 to mean 6, but only sometimes, on some pages, and not others. But I think
   we are understanding each other fine and the devs really are that bad. That’s
   why WP is so hard to work with and sucks for anything outside of a blog page.
 * or maybe I’m wrong about the devs and you are just failing to see the bug here.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468925)
 * With the [template tag](http://codex.wordpress.org/Template_Tags), [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts),
   you could use ‘caller_get_posts’=> 1 to exclude stickies from being returned 
   at the top of your query results.
 * Related:
    [Reporting Bugs](http://codex.wordpress.org/Reporting_Bugs)
 *  Thread Starter [ambius](https://wordpress.org/support/users/ambius/)
 * (@ambius)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468953)
 * I have been using ‘caller_get_posts’=>1
 * The bug I’m experiencing is when this line is not included (I’m guessing the 
   default value then would be 0). Thank you for the link to the Trac system. When
   I have more time, I will verify that my bug is unique and report it.

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

The topic ‘posts_per_page is wrong’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [ambius](https://wordpress.org/support/users/ambius/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/posts_per_page-is-wrong/#post-1468953)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
