• Resolved cosmocanuck

    (@cosmocanuck)


    Hi! I’m happily using this plugin for ages but I’m now trying to do something and having trouble. I’d like to organize my page of “past events” so the most recent is first, and the very oldest at the bottom.

    To do so, I’ve employed this code:

    <h1 style="margin-bottom: 24px">Events Now Concluded</h1>
    
    <?php $events = eo_get_events(array(
         'event_end_before'=>'today',
         'showpastevents'=>true,    //Will be deprecated, but set it to true to play it safe.
         'order' => 'DESC',
      ));
    
    if( $events ){
        global $post;
        foreach( $events as $post ){
             setup_postdata($post);
             ?>
    
               <a href='<?php the_permalink() ?>'> <h2><?php the_title(); ?></h2></a>
    			<?php eo_get_the_start('jS F Y'); ?>
               <p><?php the_excerpt(); ?></p>
    
             <?php
         }
        wp_reset_postdata();
    }else{
        echo 'No Upcoming Events';
    }
    
    ?>

    …simply adding the 'order' => 'DESC', parameter.

    But, whether I use “ASC” or “DESC”, I still get the oldest first.

    Am I doing something wrong?

    thanks!
    adam

    https://wordpress.org/plugins/event-organiser/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    Hi Adam,

    You need to set orderby to event_start. This is a known bug where if you change the order but don’t explicitly set the orderby, it doesn’t order correctly.

    Plugin Author Stephen Harris

    (@stephenharris)

    Sorry, make that eventstart.

    Plugin Author Stephen Harris

    (@stephenharris)

    … actually, this bug has been resolved a while. The above works as expected for me. However, if you are ‘grouping’ events then you may get unexpected results. Is that what you’re doing?

    Thread Starter cosmocanuck

    (@cosmocanuck)

    Thanks Stephen, setting both those parameters did the trick!

    (Not sure if I’m “grouping” events, don’t believe I was… but bottom line, it worked.)

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sorting in newest-to-oldest order’ is closed to new replies.