WordPress.org

Support

Support » How-To and Troubleshooting » Show Future Posts in Date Order

Show Future Posts in Date Order

  • I’ve got a website that I manage for a local organization. When I built the site a few years ago, I used categories to sort the various sections of the site. The organization has Events which go under the “Events” category. These events would show up in order sorted by date. Since updating WP to 3.3.1 a month or so ago, the Events now show up in the wrong order. I would like for the closest events to be on top, and the further events to be toward the bottom, e.g. March 13, June 15, November 20.

    I thought that changing the order=asc to order=desc would have fixed this, but apparently not. The following code works perfectly, except that the order of the Events won’t change! Anyone have any thoughts?

    <?php
    $my_query = new WP_Query('category_name=Events&post_status=future&order=DESC&showposts=5');
    if ($my_query->have_posts()) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    <?php the_date(); ?> - <?php the_title(); ?><br />
    
    <?php endwhile;
    }
    ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show Future Posts in Date Order’ is closed to new replies.