The gallery shortcode in WP 3.5 passes the ids as an attribute now I guess, so rather than rely on the menu_order I just changed my code, like @choeft, to use the passed in order. In my case I actually overriding the gallery shortcode in my theme, so that I can use a custom AJAX gallery for display.
You can see an example here.
My overridden function looks like this:
/*********************
CUSTOM GALLERY
*********************/
//remove default shortcode
remove_shortcode('gallery');
//Add custom gallery shortcode
add_shortcode('gallery', 'php_gallery_shortcode');
function php_gallery_shortcode($atts) {
global $post;
if ( ! empty( $atts['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
if ( empty( $atts['orderby'] ) )
$atts['orderby'] = 'post__in';
$atts['include'] = $atts['ids'];
}
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'medium',
'include' => '',
'exclude' => '',
'link' => 'file'
), $atts));
$id = intval($id);
if ( 'RAND' == $order )
$orderby = 'none';
if ( !empty($include) ) {
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
} else {
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
}
if ( empty($attachments) )
return '';
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
return $output;
}
//load styles
wp_enqueue_style( 'gallery', get_template_directory_uri() . '/library/css/gallery.css');
//load javascript
wp_enqueue_script('pmp_gallery_tmpl',get_template_directory_uri() . '/library/js/jquery.tmpl.min.js',array('jquery'),false,true);
wp_enqueue_script('easing',get_template_directory_uri() . '/library/js/jquery.easing.1.3.js',array('jquery'),false,true);
wp_enqueue_script('elastislide',get_template_directory_uri() . '/library/js/jquery.elastislide.js',array('jquery'),false,true);
wp_enqueue_script('pmp_gallery',get_template_directory_uri() . '/library/js/gallery.js',array('jquery'),false,true);
//Print out thumbnail carousel wrapper opener
printf('
<div id="rg-gallery" class="rg-gallery">
<div class="rg-thumbs">
<!-- Elastislide Carousel Thumbnail Viewer -->
<div class="es-carousel-wrapper">
<div class="es-nav">
<span class="es-nav-prev">Previous</span>
<span class="es-nav-next">Next</span>
</div>
<div class="es-carousel">
<ul>
');
//write out thumbnails
foreach ( $attachments as $image ) {
$caption = $image->post_excerpt;
$description = $image->post_content;
if($description == '') $description = $title;
$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);
$img = wp_get_attachment_image_src($image->ID, 'square-100');
$img_full = wp_get_attachment_image_src($image->ID, 'pmp-gallery-image');
// render your gallery here
printf(
'<li><a href="#"><img src="%s" data-large="%s" alt="%s" data-description="%s" /></a></li>',$img[0], $img_full[0],$image_alt,$image_alt);
}
//write out closing carousel tags
printf('
</ul>
</div>
</div>
<!-- End Elastislide Carousel Thumbnail Viewer -->
</div><!-- rg-thumbs -->
</div><!-- rg-gallery -->
');
//write out main javascript to render images
printf('
<script id="img-wrapper-tmpl" type="text/x-jquery-tmpl">
<div class="rg-image-wrapper">
{{if itemsCount > 1}}
<div class="rg-image-nav">
<a href="#" class="rg-image-nav-prev">Previous Image</a>
<a href="#" class="rg-image-nav-next">Next Image</a>
</div>
{{/if}}
<div class="rg-image"></div>
<div class="rg-loading"></div>
<div class="rg-caption-wrapper">
<div class="rg-caption" style="display:none;">
<p></p>
</div>
</div>
</div>
</script>
');
}