Title: Adding post loop over columns
Last modified: August 20, 2016

---

# Adding post loop over columns

 *  [edwardgyngell](https://wordpress.org/support/users/edwardgyngell/)
 * (@edwardgyngell)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/adding-post-loop-over-columns/)
 * Hello
 * I am wanting to display post loops over 3 columns. I have found a source that
   looks like it will do the trick but I’m not too sure how to integrate the php
   with my custom post type. I need it to display in 3 different div columns because
   the site will be responsive.
 * This is my index code:
 *     ```
       <?php get_header(); ?>
       <div id="content-wrap" style="margin-top:100px;">
       	<div class="container">
           	<div class="row">
       				<?php
   
                       global $query_string;
                       query_posts($query_string . "post_type=projects&post_status=publish&posts_per_page=50");
                       if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
                       <div class="fourcol">
                           <div class="project">
                               <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                   <?php the_post_thumbnail(); ?>
                                   <div class="project-name">
                                       <h2><?php the_title(); ?></h2>
                                   </div>
                               </a>
                           </div>
                       </div>
                       <div class="fourcol">
                           <div class="project">
                               <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                   <?php the_post_thumbnail(); ?>
                                   <div class="project-name">
                                       <h2><?php the_title(); ?></h2>
                                   </div>
                               </a>
                           </div>
                       </div>
                       <div class="fourcol">
                           <div class="project">
                               <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                   <?php the_post_thumbnail(); ?>
                                   <div class="project-name">
                                       <h2><?php the_title(); ?></h2>
                                   </div>
                               </a>
                           </div>
                       </div>
                       <?php endwhile;
                       endif; ?>
   
               </div>
       	</div><!-- End of container -->
       </div> <!-- End of profile -->
       <?php get_footer(); ?>
       ```
   
 * This is the block of code on the internet I found I think might do the trick:
 *     ```
       <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?>
   
       <div id="left-column">
       <h1><?php the_permalink(); ?></h1>
       <?php the_content(); ?>
       </div>
   
       <?php endif; endwhile; else: ?>
       <div>Alternate content</div>
       <?php endif; ?>
   
       <?php $i = 0; rewind_posts(); ?>
   
       <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query->next_post(); else : the_post(); ?>
   
       <div id="right-column">
       <h1><?php the_permalink(); ?></h1>
       <?php the_content(); ?>
       </div>
   
       <?php endif; endwhile; else: ?>
       <div>Alternate content</div>
       <?php endif; ?>
       ```
   
 * How can I integrate the two for my custom post type.
 * Thanks heaps in advance.

The topic ‘Adding post loop over columns’ is closed to new replies.

## Tags

 * [columns](https://wordpress.org/support/topic-tag/columns/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [loops](https://wordpress.org/support/topic-tag/loops/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [edwardgyngell](https://wordpress.org/support/users/edwardgyngell/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/adding-post-loop-over-columns/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
