0
我想創建一個WordPress循環,每個3列都包含一個DIV。從本質上講,我想這是環路輸出:WordPress循環換行每列3列周圍環繞
<div class="row"> // This row does have 3 sets of columns, so it will create another row
<div class="large-4 medium-4 columns panel grid">
<--Content Stuff-->
</div>
<div class="large-4 medium-4 columns panel grid">
<--Content Stuff-->
</div>
<div class="large-4 medium-4 columns panel grid">
<--Content Stuff-->
</div>
</div>
<div class="row"> // Since this row doesn't have three sets of columns, so it does not create another row
<div class="large-4 medium-4 columns panel grid">
<--Content Stuff-->
</div>
<div class="large-4 medium-4 columns panel grid">
<--Content Stuff-->
</div>
</div>
這是我目前的循環代碼:
<?php $i = 1; ?>
<?php query_posts('cat=-4'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="row">
<div class="large-4 medium-4 columns panel grid">
<--Content Stuff-->
<?php if ($i % 3 == 0) {echo '</div></div><div class="row"><div class="large-4 medium-4 columns panel grid">';} ?>
<?php $i++; endwhile; endif; ?>
</div> <!-- end .panel -->
</div>
<?php else : ?>
<?php get_template_part('partials/content', 'missing'); ?>
<?php endif; ?>
然而,這最終呈現一個完全空白的頁面,導致我相信我有PHP錯誤 - 我只是不知道在哪裏。
這可能會幫助你額外的收盤:http://stackoverflow.com/問題/ 28247770/loop-through-wordpress-posts-and-wrap-each-x-post-in-a-div –