Support

Home Forums Event Espresso Premium events listing

events listing

Posted: November 15, 2017 at 7:08 am

Viewing 5 reply threads


michaelkylephotographer

November 15, 2017 at 7:08 am

Hello,
How can I list past events from most recent to least recent?

eg the opposite of this page:

http://bsdsm.org.uk/events-past/

Thanks !


michaelkylephotographer

November 15, 2017 at 7:11 am

hj


Josh

  • Support Staff

November 15, 2017 at 9:06 am

Hi there,

Are you using the [ESPRESSO_EVENTS] shortcode there? If so, then if you do something like this:

[ESPRESSO_EVENTS show_expired=true sort=DESC order_by=start_date]

It will list the events from most recent to least recent, but it will also display upcoming events (and the upcoming events will be listed first).

There isn’t a shortcode parameter that removes upcoming events, but you can use a custom filter function to remove those. You can add the following PHP code to accomplish this:

add_action('pre_get_posts','my_remove_upcoming_ee_events', 10);
function my_remove_upcoming_ee_events($wp_query){
    if (has_filter( 'FHEE__EEH_Event_Query__apply_query_filters' ) 
        && 
        is_page('events-past')
        ){
        add_filter('posts_where', 'my_custom_ee_posts_where', 11, 2);
    }
};
function my_custom_ee_posts_where( $sql ) {
    $sql = ' AND ' 
        . EEM_Datetime::instance()->table() 
        . '.DTT_EVT_start < \'' 
        . current_time('mysql', true) 
        . '\' ';
    remove_filter('posts_where', 'my_custom_ee_posts_where', 11);
    return $sql;
}

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


michaelkylephotographer

November 15, 2017 at 9:36 am

Hi,

Thanks for this

Yes I am using this code:

[ESPRESSO_EVENTS category_slug=bsdsm-past-events show_expired=true title=’Past Events’]

Could you modify that for me?


Josh

  • Support Staff

November 15, 2017 at 9:42 am

You add the following to what you have now:

sort=DESC order_by=start_date


michaelkylephotographer

November 15, 2017 at 9:49 am

Sorted ! thanks.

Viewing 5 reply threads

The support post ‘events listing’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso