Reputation: 8368
I want to repeat after every 6 but I have no idea why this structure not repeating in a way I want.
Here is my code
<?php
query_posts( 'posts_per_page=12' );
$counter = 0;
while (have_posts()) : the_post();
if($counter % 6 == 0) :
echo '<div class="row margin-top20">';
endif; ?>
<div class="two columns">
<?php the_title(); ?>
<?php the_post_thumbnail('thumbnail'); ?>
</div>
<?php
if($counter % 6 == 0) :
echo '</div>';
endif;
endwhile; ?>
Upvotes: 2
Views: 201
Reputation: 30488
You have not incremented the counter.
Increment the counter like this:
<?php
query_posts( 'posts_per_page=12' );
$counter = 1;
while (have_posts()) : the_post();
if($counter % 6 == 0) :
echo '<div class="row margin-top20">';
endif; ?>
<div class="two columns">
<?php the_title(); ?>
<?php the_post_thumbnail('thumbnail'); ?>
</div>
<?php
$counter++;
if($counter % 6 == 0) :
echo '</div>';
endif;
endwhile; ?>
Upvotes: 4