From d906bd2f70149bc1e859a1621ac403dad90d4ffc Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 6 Sep 2012 19:19:56 +0000 Subject: [PATCH] use 'ids' parameter for explicit attachment ordering in [gallery] shortcodes. fixes #21816 git-svn-id: https://develop.svn.wordpress.org/trunk@21778 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/media.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-includes/media.php b/wp-includes/media.php index 7f735577c9..0d9b3708c6 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -801,6 +801,7 @@ function gallery_shortcode($attr) { 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', + 'ids' => '', 'include' => '', 'exclude' => '' ), $attr)); @@ -809,6 +810,12 @@ function gallery_shortcode($attr) { if ( 'RAND' == $order ) $orderby = 'none'; + if ( !empty( $ids ) ) { + // 'ids' is explicitly ordered + $orderby = 'post__in'; + $include = $ids; + } + if ( !empty($include) ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );