I need help to organize the output of posts in WordPress, I already broke my head. Grid Bootstrap. The first 3 are .col-sm-4 , and the remaining 2 entries are .col-sm-6 . And repeat this cycle.

  • Please show your attempt to implement the described functionality. What exactly did you fail? Get a list of records? Split the list into groups of three elements? At what stage did they stop? - VenZell
  • one
    if you have a cycle, then you can count it iterations, check 3 more there or not? - teran
  • one
    Count the number of displayed posts, take the remainder from division by 5. If it is 0-2, then col-sm-4, if 3-4, then col-sm-6. - KAGG Design 1:49 pm

1 answer 1

 <?php while ( have_posts() ) : the_post(); ?> <?php if($i < 3) : ?> <div class="col-sm-4"> ... <div> <?php elseif($i < 5) : ?> <div class="col-sm-6"> ... <div> <?php else: $i = -1; endif; ?> <?php $i++; ?> <?php endwhile; ?>