我想创建一个WordPress循环,它围绕每组3列包装DIV。基本上,我希望这是循环输出:
<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错误 - 我只是不知道在哪里。
答案 0 :(得分:0)
我认为这是while语句
的额外结束<?php endwhile; ?>
删除上述行,因为您已关闭了while语句