Title: listing previous posts
Last modified: August 18, 2016

---

# listing previous posts

 *  [TCLongLPC](https://wordpress.org/support/users/tclong/)
 * (@tclong)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/)
 * Site: [http://www.tclong.net/journal/](http://www.tclong.net/journal/)
 * I’d like to create a php routine that will list the titles and dates of the previous‘
   Main Entries’ category. Anyone know if there is an easy way to set this up?
 * tc

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

 *  [Joshua Sigar](https://wordpress.org/support/users/alphaoide/)
 * (@alphaoide)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/#post-327584)
 * Say “Main Entries” has category id of 2
 * `<?php $posts = get_posts( "category=2&numberposts=5″ ); ?>
    <?php if( $posts):?
   >
 * `<div id="latestMainEntries">
    <h3>Main Entries</h3> <ul> <?php foreach( $posts
   as $post ) : setup_postdata( $post ); ?>
 * `<li><span class="date"><?php the_time('F j'); ?></span> <a href="<?php the_permalink()?
   >" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></
   li>`
 * `<?php endforeach; ?>
    </ul> </div>
 * `<?php endif; ?>`
 *  Thread Starter [TCLongLPC](https://wordpress.org/support/users/tclong/)
 * (@tclong)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/#post-327588)
 * Thank you!!!!!!!!!!!!!!!!
 *  Thread Starter [TCLongLPC](https://wordpress.org/support/users/tclong/)
 * (@tclong)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/#post-327611)
 * That works very well!
    I even included an additional IF statement to exclude 
   the most recent entry.
 * `
    <?php $posts = get_posts( "category=1" ); ?> <?php if( $posts ) : ?> <?php
   $counter = 1; ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?
   > <?php if ($counter > 1) : ?> <li><center><a href="<?php the_permalink() ?>"
   title="Permanent Link to <?php the_title(); ?>" target="_blank"><?php the_title();?
   ></a></center></li> <li><span class="date"><center><?php the_time('F d, Y'); ?
   ></center></span></li><p> <?php $counter = $counter + 1; ?> <?php endif; ?> <?
   php $counter = $counter + 1; ?> <?php endforeach; ?> <?php endif; ?>
 *  [Joshua Sigar](https://wordpress.org/support/users/alphaoide/)
 * (@alphaoide)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/#post-327617)
 * Actually, the following is a better method than yours.
    `$posts = get_posts( "
   category=1&numberposts=5&offset=1″ );`
 *  Thread Starter [TCLongLPC](https://wordpress.org/support/users/tclong/)
 * (@tclong)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/#post-327908)
 * HEH! Darn, you’re right. And I thought I was being pretty clever… 😉

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

The topic ‘listing previous posts’ is closed to new replies.

## Tags

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

 * 5 replies
 * 2 participants
 * Last reply from: [TCLongLPC](https://wordpress.org/support/users/tclong/)
 * Last activity: [20 years, 2 months ago](https://wordpress.org/support/topic/listing-previous-posts/#post-327908)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
