WordPress.org

Ready to get started?Download WordPress

Forums

File Gallery
[resolved] Orders now messed up and can't be updated. (7 posts)

  1. jynk
    Member
    Posted 2 years ago #

    Just installed the update but its messed up the ordering on 4 sites. It was working before i updated as specifically checked after updating on 3 previous sites. After updating i can't save the order of the images on any of the sites.

    If something has changed would be good to know asap. Alternatively if its a glitch needs sorting soon!

    best, Dan

    http://wordpress.org/extend/plugins/file-gallery/

  2. nimmolo
    Member
    Posted 2 years ago #

    This is essentially the same issue as this thread but I'd like to reply here too.

    Without re-ordering of attachments, File Gallery is essentially broken, so it does need fixing. I wish I could help more than just drawing attention to the problem! :(

    Hopefully the plugin developers are enjoying an awesome vacation somewhere, and that's why there's no reply! :)

  3. helgatheviking
    Member
    Posted 2 years ago #

    possible solution:

    in includes/main.php change line 37 from

    'orderby' => $wpdb->posts . '.' . $attachment_orderby,

    to

    'orderby' => $attachment_orderby,

    and in includes/templating.php lines 553 and 616 from:

    $orderby = "$wpdb->posts.menu_order, $wpdb->posts.ID";

    to

    $orderby = "menu_order ID";

    or possibly even more simply:

    $orderby = "menu_order";

    as i am not sure what the point of ordering by menu order, then post id is as i don't think you can have 2 items w/ the same post id. either seems to work for me. ymmv, so backup your files first.

  4. Escape Creative
    Member
    Posted 2 years ago #

    Just for the record, it appears as if the newest version of the plugin, 1.7.5.2, updated the includes/templating.php lines 553 and 616 to:

    $orderby = "menu_order, ID";
    

    ...adding an extra comma from the feedback posted above in this thread.

    I used the 2nd line of code that helgatheviking suggested, and that worked perfectly:

    $orderby = "menu_order"
    

    Thanks to the plugin developer for such an awesome plugin, and to helgatheviking for finding this much requested bug fix. You guys rock!

  5. helgatheviking
    Member
    Posted 2 years ago #

    sure thing. i mentioned the same thing to the author who posted in the thread nimmolo posted: http://wordpress.org/support/topic/plugin-file-gallery-wont-allow-reordering?replies=5

    b/c the ordering still didn't work properly for me with the comma in place. i'm not actually sure why you'd have both, the way it is being saved in the backend should result in each attachment having a unique menu_order. as i posted over there though, it works fine if you remove that comma.

  6. Aesqe
    Member
    Plugin Author

    Posted 2 years ago #

    OK, I've found the culprit, and it's the, what should I call it... 'inflexibility' of WP_Query in regard to the MySQL ORDER BY clause, but it's probably my fault because I didn't read WP_Query reference regarding the "orderby" clause more carefully - take a look at the very last paragraph of this section:

    http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    In MySQL (I suppose in any other SQL, too), when sorting by multiple fields/columns, you should place a comma between field/column names, like I did in 1.7.5.1 - "menu_order, ID", or ""menu_order DESC, ID ASC"".

    On the other hand, when setting 'orderby' value for WP_Query, there should be no commas present in there. And ordering by multiple columns, each having a different ORDER, is, as far as I can determine, not supported (yet).

    So, to cut the jibber-jabber, I've uploaded version 1.7.5.3 of the plugin to the repository and it should be available for download now, or as an automatic update in the next 24hrs.

    Please let me know if it still doesn't work right for some reason.

    Bruno

  7. Aesqe
    Member
    Plugin Author

    Posted 2 years ago #

    So, I'm guessing it all works as expected with the latest update? :D

    If so, I'll mark this topic as resolved in 24 hours, so please comment if anything is still wrong with attachment ordering.

    Thanks! :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.