WordPress 3.5 media_order Issue Affects Custom Galleries

The revamped Add Media interface in WordPress 3.5 improves a great many things about media management. It’s fantastic and thanks go out to the team for all the hard work!

Unfortunately, the removal of a visible menu order field and the associated “Sort by Ascending / Descending” links has created an issue that affects some plugins and themes.

For instance, I often code templates that detect all images attached to a post and display them in a slideshow. In these cases I rely on the menu_order field to set the image order. Here’s a line I use often:


I’ll walk through the steps that illuminate the issue. First we’ll create a new post and upload a bunch of images to it. Using the “Uploaded to this post” filter, they appear to be in the correct order…


When we look in the DB, we see that their menu orders are actually all “0”. As we will see, this has some funny effects.


We close the Media Upload window and continue our work. When we return to the Media Upload screen, the image order appears to have been reversed.


Now, at this point there’s been no actual change in the DB. But it’s not unreasonable for the user to be a bit confused, and to manually make a change to the order. Here I’ve dragged the 01 image to the first spot:


When I do this, WordPress finally assigns a non-zero order to all of these images. Unfortunately, the order being assigned is the same (backwards) order that we are seeing via the interface.


As you can see, “image02” has been assigned a menu order of 25. To properly reorder the images involves manually dragging and dropping, which can be quite onerous with large image sets.

See: http://core.trac.wordpress.org/ticket/22758

Posted January 2013

  • ttt

    how did you fix it?

    • martyspellerberg

      I haven’t, yet. I was able to track down the lines of WP’s JS that initiate the DB update, but my knowledge of Backbone is not such that I’ve been able to trigger it out of context.

      • Tom Robak

        still no fix?

        • martyspellerberg

          Not that I know of. I’ve generally moved away from using attachments in this way and now often manage galleries using the Advanced Custom Fields plugin.

This website is hosted by Media Temple. Thanks, guys!