Salam, bootstrap silideri wp üçün inteqrasiya etməyə çalışıram. Bu sliderdə ilk item-ə active class əlavə olunmalıdır. Mən indi burda necə edim ki, döngü içindəki ilk item-ə active class əlavə olunsun?
1 | <?php while (have_posts()) : the_post() ; ?> |
2 | <div class="item"> |
3 | <?php the_post_thumbnail('thumbnail'); ?> |
4 | <div class="carousel-caption"> |
5 | <?php the_title(); ?> |
6 | </div> |
7 | </div> |
8 | <?php endwhile; ?> |
Verilmiş cavablar və yazılan şərhlər (2 cavab var)
1
həll yolunu tapdım:
1
<?php $index = 0; ?>
2
<?php while (have_posts()) : the_post() ; ?>
3
<div class="item <?php echo ($index++ == 0? "active" : ""); ?>">
4
<?php the_post_thumbnail('thumbnail'); ?>
5
<div class="carousel-caption">
6
<?php the_title(); ?>
7
</div>
8
</div>
9
<?php endwhile; ?>
1
Çoxdur yolu. Belə də olar
1
<?php
2
$class='active';
3
while (have_posts()) : the_post() ; ?>
4
<div class="item <?php echo $class; $class=''; ?>">
5
<?php the_post_thumbnail('thumbnail'); ?>
6
<div class="carousel-caption">
7
<?php the_title(); ?>
8
</div>
9
</div>
10
<?php endwhile; ?>
Sual verin
Cavab verin