最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - ACF & Bootstrap Gallery Shows Blank Slides

programmeradmin0浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I've been working on an ACF Gallery that uses the bootstrap carousel style.

I've got it to work but it seems to create an extra loop instead of closing it after the last image.

This is the code I have so far

<?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; ?>

Any help and advice would be appreciated.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I've been working on an ACF Gallery that uses the bootstrap carousel style.

I've got it to work but it seems to create an extra loop instead of closing it after the last image.

This is the code I have so far

<?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; ?>

Any help and advice would be appreciated.

Share Improve this question edited May 23, 2019 at 8:22 Matthew asked May 23, 2019 at 7:56 MatthewMatthew 136 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

change the condition like this,

  if ( ($counter % $divider == 0) && $total > $counter) : ?>
发布评论

评论列表(0)

  1. 暂无评论