Ok... i spent a day searching a solution for this issue but i'm not able to put myself out of trouble.
I have integrated Flexslider2 by myself, in a custom tailored work, filtering standard gallery output. I have followed a Tiffany Brown tutorial with some customization on it regard markup output.
Everything works flawlessy, except the gallery ordering... I'm not able to output the gallery order given via shortcode, the gallery always keep the upload (ID i think) order whathever i do.
Here is the code relative to shortcode interpretation:
static $instance = 0;
$instance++;
// Limiting what the user can do hardcoding most short code options.
extract(shortcode_atts(array(
'id' => $post->ID,
'include' => '',
'exclude' => ''
), $attrs));
$id = intval($id);
if ( !empty($include) ) {
$params = array(
'include' => $include,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order');
$_attachments = get_posts( $params );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$params = array(
'post_parent' => $id,
'exclude' => $exclude,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order');
$attachments = get_children( $params );
} else {
$params = array(
'post_parent' => $id,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order');
$attachments = get_children( $params );
}
if ( empty($attachments) ) {
return '';
}
$selector = "gallery-{$instance}";
// markup generation from here ...>
I have also tried to change orderby
parameter with others sortings, es.rand
, menu_order ID
(stated as default in current docs) , post__id
(see in some discussions but not documented) but in my code it seems this parameter is totally ignored... i can also put an arbitrary parameter like 'whateweryouwant', and the order still don't change (and no errors of course).
The filter is necessarily working because the gallery's markup put right after the code shown is working.
Someone can suggest me what's going on here?