User defined display order to the selected images in the gallery

  • Author
  • #988302


    Hi. I’m facing problem is assigning “user defined display/sorting order to the images which has been selected from a set of images using the attachment ids”.

    Example – I have added 10 images (ids 1..10) to the post as gallery. Now I want to show images only 3, 4 and 6 in gallery from the entire set of 10 images and also in order of 3, 6, 4. Note that I have skipped image id 5 and want to use my own sort / display order.

    I have used this in my post.

    [gallery include="701,699"]

    It shows two images from the entire set — which is correct but — 699 always comes before 701. I want to show 701 first.

    Can it be done? Any help will be appreciated.

    Blog url:

    The blog I need help with is



    If the photos are in a gallery, then you can change the order of the images by editing the gallery. The following help page about galleries shows the order option and the steps for setting up a gallery are at the top. See #3 under Editing a Gallery for details about image order.



    Try adding this to the gallery shortcode

    orderby="id desc"

    So that your entire gallery shortcode looks like:
    [gallery include=699,701" orderby="id desc"]



    @timethief: Yes, the images (18 nos) are in a gallery which is attached to the post. But I want to display only 3 images from the gallery and in the order of the attachment ids as mentioned along with the include statement. The order may not be ascending or descending. I guess Your assumption was the whole gallery is being displayed in ascending or descending order.

    @justjennifer: I guess the solution you gave would work only in this example because the “intended image order”


    to be in descending order. But if I want to show the images as per the order of the attachment ids given along with ‘include=’ statement for example [gallery include=”701,699,702″ then the solution would fail as the intended order is neither ascending nor descending. And this is exactly the problem… how do I show images in the same order of attachment ids as given along with the gallery include statement?

    I guess what I want to achieve can’t be done in present implementation of WP. The include statement only allows selective inclusion of images from the gallery but does not set the order and the order of the images is as per WP implementation parameters as valid with include statement.



    Includes only tell the Gallery what images should be shown. If you want a certain sort order, try the options given at the bottom of this support doc under “orderby”

The topic ‘User defined display order to the selected images in the gallery’ is closed to new replies.