如果您打开wp-includes/media.php
您将在中看到此类代码的文件gallery_shortcode
功能:
...
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) );
...
}
...
这意味着您可以将gallery短代码用于
include
属性,从中可以插入gallery所需的所有图像的ID:
[gallery include="45,59,61,62"]