Title: LEGACY: function get_media_items()
Last modified: February 16, 2017

---

# LEGACY: function get_media_items()

 *  Resolved [warrenlee](https://wordpress.org/support/users/warrenlee/)
 * (@warrenlee)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/legacy-function-get_media_items/)
 * Hi all, so for consistency, I was wondering if we could update the function so
   that the media items are ordered correctly.
 * Before the code looked like this (before 4.0.0)
    `$attachments = get_children(
   array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => '
   menu_order ASC, ID', 'order' => 'DESC') );`
 * Suggested fix should be as below (since the orderby parameter only filters what
   values are allowed)
    `$attachments = get_children( array( 'post_parent' => $post_id,'
   post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC') );`
 * The reason why we’re still using this legacy code is because we are still using
   the thick box UI to handle our media since ordering is visually better (has numbering).
 * [http://wordpress.org/support/topic/is-there-a-way-to-disable-the-new-media-manager/](http://wordpress.org/support/topic/is-there-a-way-to-disable-the-new-media-manager/)
 * Hope this is possible, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/legacy-function-get_media_items/#post-8814305)
 * Minor enhancements can be slow in coming, if at all. In the mean time you can
   override the ORDER BY clause of any posts query by using the “posts_orderby” 
   filter. The tricky part is changing only queries for get_media_items(). In order
   to be able to check other parts of the query for telling clues about the origin
   of the query, the “posts_clauses” filter may be a better choice.
 * Another option is to add the filter from a more focused hook, like “media_upload_form_url”.
   The after altering the query, your “posts_orderby” callback can then remove itself
   from the filter stack so it does not influence other queries.
 *  Thread Starter [warrenlee](https://wordpress.org/support/users/warrenlee/)
 * (@warrenlee)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/legacy-function-get_media_items/#post-9052196)
 * Sorry for the late reply!
 * Thanks for the suggestion as I will try it out!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘LEGACY: function get_media_items()’ is closed to new replies.

## Tags

 * [bug fix](https://wordpress.org/support/topic-tag/bug-fix/)
 * [legacy](https://wordpress.org/support/topic-tag/legacy/)
 * [media](https://wordpress.org/support/topic-tag/media/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [warrenlee](https://wordpress.org/support/users/warrenlee/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/legacy-function-get_media_items/#post-9052196)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
