Title: get_posts not pull all posts unless &amp;numberposts= in query
Last modified: August 20, 2016

---

# get_posts not pull all posts unless &numberposts= in query

 *  [thehobbo](https://wordpress.org/support/users/thehobbo/)
 * (@thehobbo)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/get_posts-not-pull-all-posts-unless-numberposts-in-query/)
 * Hi
 * I’ve just ran into an issue with WordPress 3.1.3 install. I’m pulling out all
   posts from a particular category in random order, all good.
    `$postslist = get_posts('
   orderby=rand&cat=24');`
 * However I’d realised it wasn’t pulling all the posts – only the latest 5. To ‘
   fix’ it I added the &numberposts= query to the string and now it works as it 
   should.
    `$postslist = get_posts('orderby=rand&cat=24&numberposts=');`
 * Is this a bug or is there a default number of posts? Or is it related to the 
   Reading Settings? (Which was set to 6 anyway?)
 * Cheers

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/get_posts-not-pull-all-posts-unless-numberposts-in-query/#post-2153744)
 * It’s not a bug. You have to specify the number of posts to retrieve when using
   get_posts.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 11 months ago](https://wordpress.org/support/topic/get_posts-not-pull-all-posts-unless-numberposts-in-query/#post-2153868)
 * The default of 5 is probably set to whatever you have in the reading settings.
 *  Thread Starter [thehobbo](https://wordpress.org/support/users/thehobbo/)
 * (@thehobbo)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/get_posts-not-pull-all-posts-unless-numberposts-in-query/#post-2153880)
 * Thanks for the replies.
    I assumed all posts would be retrieved if no `numberposts`
   value given. Seems odd that by querying with `&numberposts=` with no value returns
   all…

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

The topic ‘get_posts not pull all posts unless &numberposts= in query’ is closed
to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [thehobbo](https://wordpress.org/support/users/thehobbo/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/get_posts-not-pull-all-posts-unless-numberposts-in-query/#post-2153880)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
