Wordpress post loop with incremental value
I have a loop that displays a list item (for a slider) for each post
looped like so:
<?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; ?>
However I need to increase the value of data-slide-to by 1 for each list
item it produces. If for instance the loop had 3 posts the end result
looking like this:
<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>
How can I incrementally increase the data-slide-to value?
No comments:
Post a Comment