How can I build a loop with the bootstrap grid in several sizes?

0

I'm currently working with wordpress and came up with the following question ...

My current loop is like this ... (8 Items)

      COL-MD-6                     COL-MD-6        
    --------------------------   --------------------------

      COL-MD-6                     COL-MD-6        
    --------------------------   --------------------------

      COL-MD-6                     COL-MD-6        
    --------------------------   --------------------------

But I need something like this ...

      COL-MD-4              COL-MD-4             COL-MD-4        
    -----------------   -----------------  ----------------

      COL-MD-6                       COL-MD-6                  
    --------------------------   --------------------------

      COL-MD-4              COL-MD-4             COL-MD-4        
    -----------------   -----------------  ----------------

If someone has the solution, thank you!

    
asked by anonymous 29.08.2016 / 20:47

1 answer

1

I believe the logic is this:

<?php

$count = 0;  if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++;?>

    <?php if( $count <= 2 ) { ?>

        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">

    <?php } elseif ( $count >= 3  and $count  <= 5) {   ?>

        <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">

        <?php if( $count == 5 ){ ?>

            <?php $count = 0; ?>

        <?php } ?>

    <?php } ?>

            <!-- seu código aqui -->

        </div>

<?php endwhile; endif; ?>
    
29.08.2016 / 21:36