Title: Alternating div&#039;s for posts
Last modified: August 19, 2016

---

# Alternating div's for posts

 *  [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * (@maddtechwf)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/alternating-divs-for-posts/)
 * I have my page setup with the typical <?php if(have_posts()) : while(have_posts()):
   the post() ?><?php endwhile; endif; ?> but I have a two DIV’s inside this loop
   that needs to alternate. How could I do this with as little as code as possible.

Viewing 1 replies (of 1 total)

 *  Thread Starter [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * (@maddtechwf)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/alternating-divs-for-posts/#post-1992535)
 * Current code. I want to show 2 posts per row.
 *     ```
       <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
           <div class="posts">
               <div class="row">
                   <div class="first">
                      <h2><?php the_title(); ?></h2>
                      <?php the_content(); ?>
                   </div>
                   <div class="second">
                      <h2><?php the_title(); ?></h2>
                      <?php the_content(); ?>
                   </div>
               </div>
           </div>
       <?php endwhile; endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Alternating div's for posts’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/alternating-divs-for-posts/#post-1992535)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
