I’ve made this code which seems to work (kind of), but I would like it to make rows every time there is 3 images in a row. I’m not sure i’m clear.

WHILE there is not 3 images in a row

ADD each of them in a col

WHEN there are 3 images in a row

PUT the next three ones in a row

Can you help me to get it work ?

      <div class="row">
          <?php $i = 0 ?>


          <?php while ($i < 3 && $the_query->have_posts() ) : $the_query->the_post(); ?>
            <div class="col-md-4">
            <?php the_post_thumbnail('actus');

            $i++?>

          </div>

          <?php $i = 0; endwhile; ?>
      </div>

Read more here: Loop on col and rows


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: