我刚刚创建了这样一个BEAUTIFUL循环
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="row sectionrow" onclick="void(0)">
<div class="col-sm-4 sectionrecipes" style="background-image:url('<?php echo the_field(background_image_title); ?>');">
<div class="textsmall" >
<?php the_field(titlebreak); ?>
</div>
</div>
<div class="col-sm-8">
<div class="sectionrecipes" style="background-image:url('<?php echo the_field(background_image_detail); ?>');">
<div class="textbigrecipes">
<div class="inner">
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>"><button type="button" class="btn btn-default">READ MORE</button></a>
</div>
</div>
</div>
</div>
</div>
</div>
但是我想在第二篇文章中反转引导div的位置,并在第三篇和....上返回原始位置
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="row sectionrow" onclick="void(0)">
<div class="col-sm-8">
<div class="sectionrecipes" style="background-image:url('<?php echo the_field(background_image_detail); ?>');">
<div class="textbigrecipes">
<div class="inner">
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>"><button type="button" class="btn btn-default">READ MORE</button></a>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4 sectionrecipes" style="background-image:url('<?php echo the_field(background_image_title); ?>');">
<div class="textsmall" >
<?php the_field(titlebreak); ?>
</div>
</div>
</div>
有可能吗?
1. First declare a variable Outside the loop (like as $i =1),
检查情况。i的模式
example: if($i% 2 == 0) { -----layout First code----- }else { -----layout Second code----- }
- 增加变量值($i++)