wordpress - PHP if first div show class if else dont have class -


i have bootstrap carousel requires first slide have class of active work. jquery removes , adds class of active slide changes.

i using wordpress populate carousel , using advanced custom fields plugin so.

what im looking if first div add class of active. if not first div class not added.

here php far:

              <div class="carousel-inner">             <?php while(has_sub_field('homepage_carousel')): ?>                 <div class="item active">                     <img src="<?php the_sub_field('slide_image'); ?>" alt="...">                     <a href="<?php the_sub_field('slide_link'); ?>">explore</a>                 </div>             <?php endwhile; ?>           </div> 

          <div class="carousel-inner">         <?php $i = 0; ?>         <?php while(has_sub_field('homepage_carousel')): ?>             <div class="item <?php if($i === 0) { ?> active <?php } ?>">                 <img src="<?php the_sub_field('slide_image'); ?>" alt="...">                 <a href="<?php the_sub_field('slide_link'); ?>">explore</a>             </div>         <?php ++$i; ?>         <?php endwhile; ?>       </div> 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -