I have the standard gallery embedded in the page and want to add new images to it. When I select images and click Add to gallery button Wordpress adds them at the end. How to force it to add images at the beginning (top)?


I just fixed this after several hours of research. If one need to do the same thing, he must edit file wp-includes\js\media-views.js and replace add with unshift in this line (#2611, galleryAddToolbar):

edit.get('library').add( state.get('selection').models );

So the code will look like this:

edit.get('library').unshift( state.get('selection').models );

After that when you add images in the gallery they will appear at the top.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.