Add support for 'include' and 'exclude' to [gallery] (include="123,456" would show only these attachments regardless of the parent post, exclude="789,123" would exclude these attachments and show the rest).
git-svn-id: http://svn.automattic.com/wordpress/trunk@11771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4105845402
commit
bbefcaca3b
|
@ -661,11 +661,27 @@ function gallery_shortcode($attr) {
|
||||||
'icontag' => 'dt',
|
'icontag' => 'dt',
|
||||||
'captiontag' => 'dd',
|
'captiontag' => 'dd',
|
||||||
'columns' => 3,
|
'columns' => 3,
|
||||||
'size' => 'thumbnail'
|
'size' => 'thumbnail',
|
||||||
|
'include' => '',
|
||||||
|
'exclude' => ''
|
||||||
), $attr));
|
), $attr));
|
||||||
|
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
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) )
|
if ( empty($attachments) )
|
||||||
return '';
|
return '';
|
||||||
|
|
Loading…
Reference in New Issue