Reputation: 3
I am using wordpress and want to add a counter to each post that increases and echos out the increased number.
here is what I am doing so far which seems ridiculous. There has to be a better way haha.
$my_count=0;
$my_count++;
<div class="wow fadeInUp" data-wow-offset="100" data-wow-delay=
<?php if( $my_count == 1) { ?>"0s"<?php } ?>
<?php if( $my_count == 2) { ?>"0.3s"<?php } ?>
<?php if( $my_count == 3) { ?>"0.6s"<?php } ?>
>
Let me know if that makes any sense, but basically I am trying to increase the delay for each post without writing it out like this. (having 100 posts could be unreal as you can imagine : /
Thanks for your time in helping me out!
Upvotes: 0
Views: 190
Reputation: 5840
I assume this is in your while( have_posts() )
loop? If so, use that to your advantage:
$my_count=0;
while( have_posts() ): the_post();
?>
<div class="wow fadeInUp" data-wow-offset="100" data-wow-delay="<?php print ( $my_count * 0.3 ); ?>s">
...
</div>
<?php
$my_count++;
endwhile;
Upvotes: 2