mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 13:19:20 +01:00
use 'ids' parameter for explicit attachment ordering in [gallery] shortcodes. fixes #21816
git-svn-id: http://core.svn.wordpress.org/trunk@21778 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a0736b43ba
commit
a282823b17
@ -801,6 +801,7 @@ function gallery_shortcode($attr) {
|
|||||||
'captiontag' => 'dd',
|
'captiontag' => 'dd',
|
||||||
'columns' => 3,
|
'columns' => 3,
|
||||||
'size' => 'thumbnail',
|
'size' => 'thumbnail',
|
||||||
|
'ids' => '',
|
||||||
'include' => '',
|
'include' => '',
|
||||||
'exclude' => ''
|
'exclude' => ''
|
||||||
), $attr));
|
), $attr));
|
||||||
@ -809,6 +810,12 @@ function gallery_shortcode($attr) {
|
|||||||
if ( 'RAND' == $order )
|
if ( 'RAND' == $order )
|
||||||
$orderby = 'none';
|
$orderby = 'none';
|
||||||
|
|
||||||
|
if ( !empty( $ids ) ) {
|
||||||
|
// 'ids' is explicitly ordered
|
||||||
|
$orderby = 'post__in';
|
||||||
|
$include = $ids;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !empty($include) ) {
|
if ( !empty($include) ) {
|
||||||
$include = preg_replace( '/[^0-9,]+/', '', $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) );
|
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||||
|
Loading…
Reference in New Issue
Block a user