Can anyone help me with the logic to add a class .col-md-offset-2
to every two rows in my code below...
<?php while(have_rows('report_quotes')): the_row(); ?>
<div class="col-md-12 <?php // help me ?>">
<?php /* quote */ ?>
<?php Post::get_template_part('sections/quote'); ?>
</div>
<?php endwhile; ?>
So the output will look like this...
<div class="col-md-12">...</div>
<div class="col-md-12">...</div>
<div class="col-md-12 col-md-offset-2">...</div>
<div class="col-md-12 col-md-offset-2">...</div>
<div class="col-md-12">...</div>
<div class="col-md-12">...</div>
<div class="col-md-12 col-md-offset-2">...</div>
<div class="col-md-12 col-md-offset-2">...</div>
<div class="col-md-12">...</div>
<div class="col-md-12">...</div>
<div class="col-md-12 col-md-offset-2">...</div>
<div class="col-md-12 col-md-offset-2">...</div>
...
Can anyone help?
Thanks
You can do this by using the modulus operator (%)
So in your case -
This essentially gets the remainder for each increment and in our case we know that if the remainder is 0 (divisible by 4) or a 3, then it should be indented.