假设您正在使用库的标准功能:
[gallery ids = "1,2,3,4,5,6,7,8"]
您可以提取图像的id,而无需通过以下方式查询该帖子的附件:
preg_match(\'/\\[gallery.*ids=.(.*).\\]/\', get_the_content(), $ids);
然后创建这些值的数组:
$ids = explode( \',\' $ids[1] );
最后检查特征图像的id是否存在,并获取其位置(我认为它不存在,除非你不将其放在图库中):
$pos = array_search( get_post_thumbnail_id( get_the_ID ), $ids);
取消设置该值:
unset($ids[$pos]);
现在您拥有了所有附件ID,而不是存储在$ids数组中的特征图像。
UPDATE
<?php
//// GETS OUR IMAGES
$query_images_args = array(
\'post_type\' => \'attachment\',
\'post_mime_type\' =>\'image\',
\'post_status\' => \'inherit\',
\'posts_per_page\' => -1,
\'post_parent\' => get_the_ID(),
\'exclude\' => get_post_thumbnail_id(),
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
);
$images = get_posts( $query_images_args );
?>
<div class="sidebar-item not-in-responsive">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(\'#property-gallery-thumbs\').propertyGallery();
});
</script>
<ul id="property-gallery-thumbs">
<?php
$i = 1;
/// IF WE HAVE MORE THAN JUST ONE IMAGE
if( $images ) : foreach( $images as $image ) : setup_postdata( $image ); ++$i;
?>
<li class="thumb<?php if($i==1) { echo \' current\'; } ?><?php if($i%3 == 0) { echo \' last\'; } ?>">
<span class="hidden full"><?php echo wp_get_attachment_url( $image->ID ); ?></span>
<span class="hidden main"><?php echo ddTimthumb(wp_get_attachment_url( $image->ID ), 680, 450); ?></span>
<span class="thumb"><img src="<?php echo ddTimthumb(wp_get_attachment_url( $image->ID ), 76, 76); ?>" alt="<?php the_title() ?>" title="<?php the_title(); ?>" /></span>
</li>
<?php endforeach; wp_reset_postdata(); ?>
</ul>
<!-- /#property-gallery-thumbs/ -->
</div>
<?php endif; ?>