• 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

    (@geofftswin)

    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

    (@vaughan-van-dyk)

    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.