• Hi all,

    I’m having a bit of a problem with a simple get_posts() request in the sidebar.php of my theme.

    I’m using the following code taken directly from the codex:

    $postslist = get_posts('numberposts=10&order=ASC&orderby=title');

    This does indeed return all 6 actual posts but not in ascending date order as expected. The latest test post I have slotted in should be at the top but actually appears sixth on the list. I’ve checked the other posts’ published dates and there seems to be no issue there – The dates are correct. I thought it might be to do with the ID but that doesn’t seem t be the case either.

    The order that the posts are returned in is as follows (ID / post date):

    194 | August 27, 2010
    350 | August 15, 2010
    372 | August 26, 2010
    343 | June 6, 2010
    357 | August 1, 2010
    480 | September 10, 2010

    As you can see the the posts aren’t even in date order. Can anyone shed any light on what might be happening here?

    Thanks for any help in advance
    Dan

Viewing 1 replies (of 1 total)
  • You have an ‘orderby=title’ parameter in your query, so the posts should be in order by title. Give this a try:

    $postslist = get_posts('numberposts=10&order=ASC');

Viewing 1 replies (of 1 total)

The topic ‘get_posts() returning posts in odd order’ is closed to new replies.