Sort gallery by ID?

  • Author
    Posts
  • #254662

    phattrance
    Member

    i wonder if there is a gallery code for sorting the image by id?

    the problem is that when i upload a file “name01, name02, name03” the name03 will come first and name 02 second and name01 will be in the end of the post, i want it to be like: name01, name02, name03.

    i am using this gallery shortcut: [gallery columns="1" size="medium"]

    #254903

    nickmomrik
    Staff

    There is an orderby option that you can use.

    http://codex.wordpress.org/Using_the_gallery_shortcode

    It’s much easier to simply click on the Add an Image button and then change to the Gallery tab, where you can drag and drop the images to whatever order you want them to appear in the gallery.

    #254968

    phattrance
    Member

    Hi! i know that i can drag and drop the images but its a pain when you have 40+ pics on at post, its takes just to much time to drag and drop images by id :)

    about the shortcut, i did a take a look at the gallery shortcut page but didnt understand what to write in the shortcut code :/ what should i write in this shortcut to have the images sorted by name? [gallery columns="1" size="medium"]

    #254971

    justjennifer
    Moderator

    Put orderby=”ID ASC” between the brackets.

    It appears that file name is ID, so if you want your photos in a different order, you’ll have to do it manually anyway.

    #254972

    deltafoxtrot
    Member

    Try this:
    gallery columns="1" size="medium" sortby="ID DESC"]

    #254973

    justjennifer
    Moderator

    Let me clarify that ID one step further.

    ID is the name of the file when you upload it; not the title or caption you may give it after uploading.

    #254986

    phattrance
    Member

    hmmm i tried both [gallery columns="1" size="medium" sortby="ID DESC"] and

    [gallery columns="1" size="medium" orderby="ID ASC"]

    but non of those shortcuts codes seems to work :/ the name1 pic is still at the end of the post while name45 pic is on top :(

    any other codes that i can try?

    #254987

    justjennifer
    Moderator

    Then orderby=”ID DESC” should do it.

    #254996

    If not, how about orderby=”post_name ASC” ?

    #255001

    phattrance
    Member

    dammit, both

    [gallery columns="1" size="medium" orderby="ID DESC"]

    and

    [gallery columns="1" size="medium" orderby="post_name ASC"]

    didnt work. its still the same as before :/

    #255018

    justjennifer
    Moderator

    phattrance, are you talking about a blog you have here on wordpress.COM? I know that you were on COM at one point (and remember your question to me about the social bookmarking tool I’m using), but it looks like the current blog is a self-hosted WordPress install.

    #255023

    phattrance
    Member

    i just moved to a .org blog but since the gallery shortcut is the same i asked here (cause the help here is WAAAAY better than the .org forum)

    anyway, i have tried different shortcuts and EVEN did the sorting by “order” box @ add media and it still did put the name5 pc on top and the name1 pic were at the end of the post..

    i found a way to make it alright but its stupid that i need to do it this way :) i just renamed the name05 pic to name01 and the image uploader will upload it backwards, lol

    #255024

    justjennifer
    Moderator

    The only trouble with asking here is that in general the software you are using is different than WordPress.COM users use, so your results may be different. Just sayin’…

    #255108

    hervej
    Member

    Same need and same problem than you Phattrance, see my post https://en.forums.wordpress.com/topic/problem-with-gallery-ordering-orderby-desc-or-asc?replies=2#post-238708

    Hope the WP team will be able to fix it

The topic ‘Sort gallery by ID?’ is closed to new replies.