Ordering slides from post_id

When using the post_id shortcode, the gallery created shows the images in the order uploaded, rather than in the order they have been sorted into in the media library.

I have been experimenting with the shortcode parameters. The documentation here:

https://tribulant.com/docs/wordpress-slideshow-gallery/9532/shortcodes-hardcodes-for-displaying-a-slideshow/

has duplicate explanations 'orderf' and 'orderd', both of which appear to be to instructions for 'orderd'; "Set to ‘DESC’ to order the slides in a descending order and ‘ASC’ to order the slides in a ascending order. Leave this shortcode parameter to order by the order set on the slides."

The plugin code has 'orderf' listed as "order field" but does not include any examples:
'orderf'		=>	false,	// order field
'orderd' => false, // order direction (ASC/DESC)
In the plugin code, I find the line;
if (!in_array($s['orderf'], ['id', 'date', 'name', 'type', 'created', 'order'], true))

but none of those options seem to change the order of the images in the slideshow except 'name' which sorts them by filename.
Is there a way to use 'orderf' to sort the images by their order in the media library? Alternatively, is there another way to use something other than upload date to sort the images?

Comments

  • 0 Comments sorted by
  • Vote Up0Vote Down
    I figured out the issue.
    ​By editing the slideshow-gallery.php lines;

    ​$s['orderby'] = array('order', "ASC"); // Default fallback
    and

    $s['orderf'] = 'order'; // Default fallback
    ​to reference 'menu_order' rather than 'order' as the default fallback, the plugin correctly uses the menu order to display the images.

    ​This change should probably be included in future builds of the plugin:
    ​if (!in_array($s['orderby'], ['id', 'date', 'name', 'type', 'created' , 'order' , 'random'], true)) {
    $s['orderby'] = array('menu_order', "ASC"); // Default fallback
    }
    // Additional validation based on the context
    if (!in_array($s['orderf'], ['id', 'date', 'name', 'type', 'created', 'order'], true)) {
    $s['orderf'] = 'menu_order'; // Default fallback
    }


Sign In or Register to comment.