在WordPress 3.5之后,默认情况下,gallery短代码现在包括图像ID。像这样[gallery ids="729,732,731,720"]
它也保留了顺序,所以打开名为carousel-gallery-jquery.php
并替换这一行:(第140行附近)
$attachments = get_children( array(\'post_parent\' => $id, \'post_status\' => \'inherit\', \'post_type\' => \'attachment\', \'post_mime_type\' => \'image\', \'order\' => $order, \'orderby\' => $orderby) );
使用此选项:
if ( isset($include) && !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 ( isset($exclude) && !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) );
}
然后在第121行该函数的顶部添加以下内容:
if ( ! empty( $attr[\'ids\'] ) ) {
// \'ids\' is explicitly ordered, unless you specify otherwise.
if ( empty( $attr[\'orderby\'] ) )
$attr[\'orderby\'] = \'post__in\';
$attr[\'include\'] = $attr[\'ids\'];
}
你应该没事:)