Loop with break in the middle

Try using a loopcounter based on the post number count – provides for more flexibility

<?php if (have_posts()) : ?>
   <?php $count = 0; ?>
       <?php while (have_posts()) : the_post(); ?>
           <?php $count++; ?>
    // if you are in your first post
           <?php if ($count == 1) : ?>
    // do whatever you want to display your posts *assuming you want a featured top level*
           <?php elseif ( in_array($count, array( 2,3,4,5 ) )) : ?>      
    // do whatever you want to display your posts
           <?php elseif ($count == 6 ) : ?>  
    // do whatever you want to display your posts - this is probably the middle guy on a 3x3 grid with a featured 1st post
           <?php elseif ( in_array($count, array( 7,8,9,10 ) )) : ?>      
           <?php else : ?>
           <?php endif; ?>
        <?php endwhile; ?>
    <?php else : ?>
<?php endif; ?>

Leave a Comment