Title: Displaying Posts
Last modified: August 19, 2016

---

# Displaying Posts

 *  [geofftswin](https://wordpress.org/support/users/geofftswin/)
 * (@geofftswin)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/displaying-posts-2/)
 * I can display my posts using the following code:
 *     ```
       <?php
       global $post;
       $mpyposts = get_posts('numberposts=2&category=6');
       foreach ($mpyposts as $post):
       setup_postdata($post); ?>
       <?php  //to check against expiration date;
   
       $currentdate = date("Ymd");
   
       $expirationdate = get_post_custom_values('expiration');
   
       if (is_null($expirationdate)) {
   
                   $expirestring = '30005050'; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP;
   
       } else {
   
       if (is_array($expirationdate)) {
   
                   $expirestringarray = implode($expirationdate);
   
                   }
   
       $expirestring = str_replace("/","",$expirestringarray);
   
       } //else
   
        if ( $expirestring > $currentdate ) { ?>
       <ul class="posts">
       <?php the_content(); ?>
       </ul>
       <?php } //end if for expiration; ?>
       <?php endforeach; ?>
       ```
   
 * however I want to display them in the reverse order (most recent at bottom), 
   so I change
    `$mpyposts = get_posts('numberposts=2&category=6');` to `$mpyposts
   = get_posts('numberposts=2&category=6&order=ASC');` and everything disappears
   completely. What can I do to get it to work correctly?

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

 *  Thread Starter [geofftswin](https://wordpress.org/support/users/geofftswin/)
 * (@geofftswin)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/displaying-posts-2/#post-864409)
 * anybody got any ideas? The problem seems to be with the
    order=ASC filter, however
   I’ve used it elsewhere without problems to display a list of titles, but in this
   case I’m trying to display the posts themselves.
 *  [Vaughan](https://wordpress.org/support/users/vaughan-van-dyk/)
 * (@vaughan-van-dyk)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/displaying-posts-2/#post-864425)
 * Hi,
 * I can’t fully test your code unfortunately because you’re using various custom
   values in there, but whenever using the **order** parameter, I also like to add
   the **orderby** parameter so that there can be no doubt as to what it should 
   sort on.
 * So perhaps try the following:
 *     ```
       $mpyposts = get_posts('numberposts=2&category=6&order=ASC&orderby=date');
       ```
   
 * Good luck.
    Vaughan

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

The topic ‘Displaying Posts’ is closed to new replies.

## Tags

 * [display post](https://wordpress.org/support/topic-tag/display-post/)
 * [displaying](https://wordpress.org/support/topic-tag/displaying/)
 * [expiring](https://wordpress.org/support/topic-tag/expiring/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Vaughan](https://wordpress.org/support/users/vaughan-van-dyk/)
 * Last activity: [17 years, 6 months ago](https://wordpress.org/support/topic/displaying-posts-2/#post-864425)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
