• Resolved warrenlee

    (@warrenlee)


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

    https://www.ads-software.com/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

    (@bcworkz)

    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

    (@warrenlee)

    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.