Title: Adding get_posts and reordering
Last modified: August 21, 2016

---

# Adding get_posts and reordering

 *  [viveramedia](https://wordpress.org/support/users/viveramedia/)
 * (@viveramedia)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/adding-get_posts-and-reordering/)
 * 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](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/adding-get_posts-and-reordering/#post-3930777)
 * 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.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/adding-get_posts-and-reordering/#post-3930777)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
