• Hi All.

    I was struggling a bit with getting this plugin to display images in my gallery in the custom order that I had configured in my post and not just by “ID ASC”.

    I made a change to the file: “image-gallery-reloaded/image-gallery-reloaded.php” (press edit from the plugins page to open up the file editor).

    Here’s a step by step guide:

    1. Scroll down to the function: “function igr_gallery_shortcode($attr)”
    2. Just after you see “$count = 1;”, replace the following code:

    ————————
    if(!empty($ids))
    {
    $ids = preg_replace( ‘/[^0-9,]+/’, ”, $ids );

    $_attachments = get_posts ( array(
    ‘include’ => $ids,
    ‘post_type’ => ‘attachment’,
    ‘post_mime_type’ => ‘image’,
    ‘orderby’ => $orderby
    )
    );
    $attachments = array();
    foreach ( $_attachments as $key => $val )
    {
    $attachments[$val->ID] = $_attachments[$key];
    }

    }
    ————————
    with this one:
    ————————

    if(!empty($ids))
    {
    $ids = preg_replace( ‘/[^0-9,]+/’, ”, $ids );

    $ids_array = explode(‘,’, $ids);

    $_attachments = array();
    foreach ( $ids_array as $get_this_id ) {
    $_attachments[] = get_post($get_this_id);
    }

    $attachments = array();
    foreach ( $_attachments as $key => $val )
    {
    $attachments[$val->ID] = $_attachments[$key];
    }

    }
    ————————
    Now it should work.

    Perhaps this could be invorporated into the next version of the plugin?
    (I’ll try to make a branch on github).

    http://wordpress.org/extend/plugins/image-gallery-reloaded/

Viewing 15 replies - 1 through 15 (of 17 total)
Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Making the gallery respect image order’ is closed to new replies.