Title: displaying separate posts based on sequential order
Last modified: August 20, 2016

---

# displaying separate posts based on sequential order

 *  [harberg](https://wordpress.org/support/users/harberg/)
 * (@harberg)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/displaying-separate-posts-based-on-sequential-order/)
 * Hello All,
 * I am trying to figure out how to display the three most recent posts in three
   separate areas of my main page. I have three boxes that will have the three most
   recent posts in them. Box 1 has the most recent, box 2 the second most recent,
   and box 3 the third most recent. When a new post is made, what is in the boxes
   will change. I only want to display one post per box.
 * I have tried
 *     ```
       <?php
       $posts=get_posts('numberposts=3&offset=0');
       foreach ($posts as $post) :
       ?>
       <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       <p><?php echo limit_words(get_the_excerpt(), '40'); ?></p>
       <a href="<?php the_permalink(); ?>">Read More >></a>
       <?php endforeach ?>
       ```
   
 * This works until I reload the page and it keeps adding posts into the boxes. 
   Any help would be great. Thank you very much.
 * Harberg

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

 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/displaying-separate-posts-based-on-sequential-order/#post-2615466)
 * You need to add the posts to a div
 *     ```
       <?php
       $posts=get_posts('numberposts=3&offset=0'); $counter=0;
       foreach ($posts as $post) :
       $counter++; $class =($counter == 3) ? ' last' : '';	?>
       <div class="box<?php echo $class; ?>">
       	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       	<p><?php echo limit_words(get_the_excerpt(), '40'); ?></p>
       	<a href="<?php the_permalink(); ?>">Read More >></a>
       </div>
       <?php endforeach; ?>
       ```
   
 * Stylesheet:
 *     ```
       .box {
       	width: 30.75%;
       	margin-right: 3.8%;
       	float: left;
       	min-height: 1px;
       }
       .last {
       	margin-right: 0px;
       }
       ```
   
 * HTH
 * David
 *  Thread Starter [harberg](https://wordpress.org/support/users/harberg/)
 * (@harberg)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/displaying-separate-posts-based-on-sequential-order/#post-2615483)
 * David,
 * Thank you this is working great. There is one problem, no the get_excerpt is 
   no longer showing up.
 * Any ideas what caused this?
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/displaying-separate-posts-based-on-sequential-order/#post-2615565)
 * The excerpt by default is set at 40, the excerpt does not need the <p> or echo,
   so you could change it to:
 *     ```
       <?php the_excerpt(); ?>
       ```
   
 * Also after the endforeach, add a clear.
 *     ```
       <div style="clear:both:"></div>
       ```
   
 * HTH
 * David

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

The topic ‘displaying separate posts based on sequential order’ is closed to new
replies.

## Tags

 * [get_post](https://wordpress.org/support/topic-tag/get_post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/displaying-separate-posts-based-on-sequential-order/#post-2615565)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
