<?php while($slider -> have_posts()) : $slider->the_post(); ?>
<div class="slide">
<div class="slide-top"><?php the_title();?></div>
<div class="slide-bottom"><?php the_content();?></div>
<?php the_post_thumbnail();?>
</div>
<?php endwhile; ?>
Добрый день есть такой код. Подскажите пожалуйста как сделать что бы у первого элемента из цикла был класс active
К примеру выведет 3 элемента с классом slide а первый будет иметь и класс active
<?php $i=0; while($slider -> have_posts()): $slider->the_post(); ?>
<div class="slide"<?php if ($i === 1) echo ' class = "active"';?>>
<div class="slide-top"><?php the_title();?></div>
<div class="slide-bottom"><?php the_content();?></div>
<?php the_post_thumbnail();?>
</div>
<?php $i++; endwhile; ?>
current_post - Индекс отображаемого сообщения.
<?php while($slider -> have_posts()) : $slider->the_post(); ?>
<div class="slide <?php if ( $slider->current_post == 0 ) : ?>active<?php endif; ?>">
<div class="slide-top"><?php the_title();?></div>
<div class="slide-bottom"><?php the_content();?></div>
<?php the_post_thumbnail();?>
</div>
<?php endwhile; ?>
Современные инструменты для криптотрейдинга: как технологии помогают принимать решения
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости