我一直在开发一个ACF画廊,它使用引导式旋转木马风格。
我已经让它工作了,但它似乎创建了一个额外的循环,而不是在最后一个图像后关闭它。
这是我目前掌握的密码
<?php
$images = get_field(\'slider_portfolio\');
$divider = 2;
if( $images ): ?>
<div id="mini-carousel2" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" style="max-height: 250px;min-height: 250px">
<div class="carousel-item active">
<div class="row">
<?php
$total = count( $images );
$counter = 0;
foreach( $images as $image ):
$counter++; ?>
<div class="col-md-6 col-sm-12 col-xs-12">
<a href="<?php echo $image[\'sizes\'][\'large\']; ?>" class="fancybox img-<?php echo $counter; ?>" rel="mini" data-toggle="lightbox" data-gallery="portfolio-gallery">
<img class="img-fluid" src="<?php echo $image[\'sizes\'][\'large\']; ?>" alt="<?php echo $image[\'title\']; ?>" />
</a>
</div>
<?php $current_position = $images->$image + 1;
if (/* $image < $image->$total && */ $counter % $divider == 0) : ?>
</div>
</div>
<div class="carousel-item">
<div class="row">
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
</div>
<!-- Controls -->
<a class="carousel-control-prev" href="#mini-carousel2" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span></a>
<a class="carousel-control-next" href="#mini-carousel2" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span></a></div>
<?php endif; ?>
如有任何帮助和建议,将不胜感激。