2016-03-21 5 views

Antwort

2

Diese Sie heraus

$args = array(
    'post_type' => 'college', 
    'posts_per_page' => -1, 
    'order' => 'DESC', 
    'orderby' => 'menu_order' 
); 

$the_query = new WP_Query($args); 
if ($the_query->have_posts()) : 
    $counter = 0; 
    while ($the_query->have_posts()) : $the_query->the_post(); 
     if ($counter % 4 == 0) : 
      echo $counter > 0 ? "</div>" : ""; // close div if it's not the first 
      echo "<div class='row'>"; 
     endif; 
     ?> 
     <div class="col-3"> 
      <?php the_title(); ?> 
     </div> 
     <?php 
     $counter++; 

    endwhile; 
endif; 
wp_reset_postdata(); 
?> 

Angepasst von Wrapping a div around every third item in a foreach loop PHP

+0

Dank sortieren sollte @chapskev. Es funktioniert perfekt! –

+0

Großartig :) es war eine schöne Herausforderung, hatte ich ein paar Kritzeleien – chapskev

Verwandte Themen