开发者

How to make this "loop" pattern on wordpress?

Is anybody know how to make loop with this pattern in wordpress?

<div class="row">
    <div class="post1">...</div>
    <div class="post2">...</div>
</div>
<div class="row开发者_开发技巧">
    <div class="post3">...</div>
    <div class="post4">...</div>
</div>
<div class="row">
    <div class="post5">...</div>
</div>

Thanks.


<?php 
$odd = true;
while ( have_posts() ) : the_post(); 
if($odd){ ?>
    <div class="row">
<?php } ?>
        <div class="post<?php the_ID(); ?>">
        <!-- contents -->
        </div>
<?php if(!$odd){ ?>
    </div>
<?php } 
$odd = !$odd;
endwhile;

if(!$odd){ ?>
    </div>
<?php } 
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜