Title: 2 column multi loop
Last modified: August 19, 2016

---

# 2 column multi loop

 *  Resolved [dangayle](https://wordpress.org/support/users/dangayle/)
 * (@dangayle)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/)
 * I’m trying to design a 2 column newspaper-style theme with a unique aspect: All
   even posts are displayed in the left column, while all odd posts are displayed
   in the right column.
 * What I’m having a hard time doing is the split. Getting a multi-loop split via
   categories is easy, but how do you identify even or odd posts and exclude either
   from a loop?
 * Thanks

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-673968)
 * I don’t think that’s a viable idea, unless you can define what is an even and
   what is an odd post.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-673990)
 * Here is a dual-loop structure which works off the default posts query and should
   do what you’re asking:
 *     ```
       <div class="odd-column">
       <?php while(have_posts()) : ?>
       <?php
       $postcount++;
       if( ($postcount % 2) == 0 ) : // skip 'even' posts
       	$wp_query->next_post();
       else :
       ?>
       <?php the_post(); ?>
   
       ~ posts go here ~
   
       <?php endif; ?>
       <?php endwhile; ?>
       </div>
   
       <?php $postcount = 0; rewind_posts(); ?>
   
       <div class="even-column">
       <?php while(have_posts()) : ?>
       <?php
       $postcount++;
       if( ($postcount % 2) != 0 ) : // skip 'odd' posts
       	$wp_query->next_post();
       else :
       ?>
       <?php the_post(); ?>
   
       ~ posts go here ~
   
       <?php endif; ?>
       <?php endwhile; ?>
       </div>
       ```
   
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-673992)
 * I stand corrected 🙂
    For PHP gurus like Kaf… everything is possible!
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-673993)
 * Well, not *everything*. `;)`
 *  Thread Starter [dangayle](https://wordpress.org/support/users/dangayle/)
 * (@dangayle)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674000)
 * AWESOME! I’ll check it right now!
 *  [ckortman](https://wordpress.org/support/users/ckortman/)
 * (@ckortman)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674009)
 * how do you think the comments work on this site or other sites, with the alternating
   colours 😉
 * if you can think of it, it can be done… somehow.
 *  Thread Starter [dangayle](https://wordpress.org/support/users/dangayle/)
 * (@dangayle)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674058)
 * It’s working great.
 * To make things look as clean as possible, I’ve set the main loops to the_excerpt
   in index.php. Since pages default to index.php, is that a good idea? Or should
   I make a separate template for the main page, and code index.php normally?
 * I’ll have to wrap my head around how single.php and page.php, etc., will be formatted,
   but that’s just a matter of time now that I have this part down.
 * Thanks again!
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674063)
 * “_Or should I make a separate template for the main page, and code index.php 
   normally?_“
 * Yes. That is, I would move the dual-loop stuff over to a home.php, and allow 
   index.php to act as a fall-back for any post query types that need it.
 * Reference:
    [http://codex.wordpress.org/Template_Hierarchy](http://codex.wordpress.org/Template_Hierarchy)
 *  [evilpupil](https://wordpress.org/support/users/evilpupil/)
 * (@evilpupil)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674395)
 * dear Kaf,
 * same as the above, can u guide me on how to make a 3 multicolumn loop? for example
   take a look at this site reformrevolution[dot]com. i’ve tried the method from
   perishablepress[dot]com but when i click the next page, it returns the same post.
   here’s the code :
 * >  // FIRST LOOP: display posts 1 thru 5
   >  <?php query_posts(‘showposts=5’); ?
   > > <?php $posts = get_posts(‘numberposts=5&offset=0’); foreach ($posts as $post):
   > start_wp(); ?> <?php static $count1 = 0; if ($count1 == “5”) { break; } else{?
   > >
   > <?php the_title(); ?>
   >  <?php the_content(); ?>
   > <?php $count1++; } ?>
   >  <?php endforeach; ?>
   > // SECOND LOOP: display posts 6 thru 10
   >  <?php query_posts(‘showposts=5’); ?
   > > <?php $posts = get_posts(‘numberposts=5&offset=5’); foreach ($posts as $post):
   > start_wp(); ?> <?php static $count2 = 0; if ($count2 == “5”) { break; } else{?
   > >
   > <?php the_title(); ?>
   >  <?php the_content(); ?>
   > <?php $count2++; } ?>
   >  <?php endforeach; ?>
   > // THIRD LOOP: display posts 11 thru 15
   >  <?php query_posts(‘showposts=5’); ?
   > > <?php $posts = get_posts(‘numberposts=5&offset=10’); foreach ($posts as $
   > post) : start_wp(); ?> <?php static $count3 = 0; if ($count3 == “5”) { break;}
   > else { ?>
   > <?php the_title(); ?>
   >  <?php the_content(); ?>
   > <?php $count3++; } ?>
   >  <?php endforeach; ?>
 * thank you..
 *  [towmater](https://wordpress.org/support/users/towmater/)
 * (@towmater)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674396)
 * interested to see if you found an answer to this question. I’m having a similar
   problem.
 *  [dreamyguy](https://wordpress.org/support/users/dreamyguy/)
 * (@dreamyguy)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674397)
 * I was wondering if there was a more elegant solution to this problem because 
   one if/else should have been enough to get this done… I came across this solution:
 * “Replace have_posts with this in the loop:
 * >  <?php
   >  $x=0; if (have_posts()) : ?>
 * Add a check and condition for odds and evens where your content for each post
   begins:
 * >  <?php if ($odd = $x%2){?>
   >  <div class=”odd”> <?php } else { ?><div class=”
   > even”> <?php } ?>
 * Make sure you close those div tags after your post content.
 * Then replace the endwhile in your loop with this:
 * >  <?php
   >  $x++; endwhile; ?>
 * Now you can go CSS crazy changing the background, colors, sizes for each alternate
   post!”
 * Would that be correct?

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘2 column multi loop’ is closed to new replies.

## Tags

 * [column](https://wordpress.org/support/topic-tag/column/)
 * [even](https://wordpress.org/support/topic-tag/even/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [multi-loop](https://wordpress.org/support/topic-tag/multi-loop/)
 * [odd](https://wordpress.org/support/topic-tag/odd/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 7 participants
 * Last reply from: [dreamyguy](https://wordpress.org/support/users/dreamyguy/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/2-column-multi-loop/#post-674397)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
