• 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)
  • It’s not a bug. You have to specify the number of posts to retrieve when using get_posts.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The default of 5 is probably set to whatever you have in the reading settings.

    Thread Starter thehobbo

    (@thehobbo)

    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.