• Hi guys,

    I am doing a series of loops which uses:

    $myposts = get_posts("category=$category->id");

    However I need to do something like:

    $myposts .= get_posts("category=$category->id"); so the var $myposts is added to on each loop. I then need to re-order $myposts by published date and re-loop.

    Any idea how I can achieve this?

    Thanks,

    Dave

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Use array_merge() to combine the results of each call to get_posts() into a single, large array. You can then use usort() to sort the resulting array by some underlying object property such as publish date.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding get_posts and reordering’ is closed to new replies.