Created
January 20, 2013 21:31
-
-
Save ebinnion/4581906 to your computer and use it in GitHub Desktop.
WordPress Loop Group of Three
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (have_posts()) : | |
$i=0; // counter | |
while(have_posts()) : the_post(); | |
if($i%3==0) { // if counter is multiple of 3, put an opening div ?> | |
<!-- <?php echo ($i+1).'-'; echo ($i+3); ?> --> | |
<div class="cf"> | |
<?php } ?> | |
<div class="col3 toolbox"> | |
<div class="head"> | |
<h5 style="text-align:center;"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h5> | |
<div class="aligncenter"><a href="<?php the_permalink() ?>"><?php if(has_post_thumbnail()) { the_post_thumbnail('featured'); } ?></a></div> | |
</div> | |
<p><?php echo get_post_meta( get_the_ID(), 'ta_post_review_summary', true) ?></p> | |
</div> | |
<?php $i++; | |
if($i%3==0) { // if counter is multiple of 3, put an closing div ?> | |
</div> | |
<div class="line-separator"></div> | |
<?php } ?> | |
<?php endwhile; ?> | |
<?php | |
if($i%3!=0) { // put closing div here if loop is not exactly a multiple of 3 ?> | |
</div> | |
<?php } ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment