我有一个循环显示每个循环的列表项(对于滑块),如下所示:
<?php while (have_posts()) : the_post(); ?>
<li data-target="#myCarousel" data-slide-to="0"<?php if( $wp_query->current_post == 0 && !is_paged() ) { ?> class="active"<?php } else { ?><?php } ?>></li>
<?php endwhile; ?>
Run Code Online (Sandbox Code Playgroud)
但是,对于它生成的每个列表项,我需要将data-slide-to的值增加1.例如,如果循环有3个帖子,最终结果如下所示:
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
Run Code Online (Sandbox Code Playgroud)
如何逐步增加数据 - 幻灯片 - 值?