Skip to content

Instantly share code, notes, and snippets.

Created July 5, 2012 17:20
Show Gist options
  • Save anonymous/3055015 to your computer and use it in GitHub Desktop.
Save anonymous/3055015 to your computer and use it in GitHub Desktop.
WP Query loop - in multiples of 3 posts in containing div.
<?php
$currentID = get_the_ID();
$featured = new WP_Query(array(
'post_type' => 'post',
'order' => 'DESC',
'posts_per_page' => 8,
'post__not_in' => array($currentID)
)); ?>
<?php $i=1; if ($featured->have_posts()) : ?>
<div id="slider-wrapper">
<?php while ($featured->have_posts()) : $featured->the_post(); if ($i==1 || $i%3==1) echo '<div class="slide-group">'; ?>
<div class="slide">
<?php the_title(); ?>
</div>
<?php if($i%3==0) echo '</div>'; $i++; endwhile; ?>
</div>
<?php unset($featured); endif; wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment