Forums

get_posts not pull all posts unless &numberposts= in query (4 posts)

  1. thehobbo
    Member
    Posted 11 months ago #

    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

  2. esmi
    Theme Diva & Forum Moderator
    Posted 11 months ago #

    It's not a bug. You have to specify the number of posts to retrieve when using get_posts.

  3. Ipstenu
    Half-Elf Support Rogue & Mod
    Posted 11 months ago #

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

  4. thehobbo
    Member
    Posted 11 months ago #

    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...

Reply

You must log in to post.

About this Topic

Tags