Displaying Posts
-
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?
-
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.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
The topic ‘Displaying Posts’ is closed to new replies.