For venues: Display future events first

WordPress Event Management, Calendars & Registration Forums General Question For venues: Display future events first

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 8 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2844

    Currently when viewing a venue page, you get a list of all events that have happened, and will happen there – starting with the oldest. Without selecting the option that basically hides all past events – even on the calendar – is there a way of making that list show future events at the venue first/only, starting with the soonest?

    What I want to avoid is where there are so many past events displayed for a venue that every future one is pushed onto page 2 or more.
    I don’t mind if past events have to be hidden on venue pages (though I’d rather have a separate list for these if possible) but I don’t want them to disappear of Event Organiser completely.
    Thanks in advance, I hope this isn’t too troublesome.

    David
    #2849

    Hi David – which version are you using? Selecting that option doesn’t (shouldn’t) hide the past events on the calendars. The text on the settings page I think is out of date – widgets have their own option and the calendar shortcodes show past events by default.

    You can, however, use the following code to hide past events:

    add_action('pre_get_posts','myprefix_hide_past_events',7);
    function myprefix_hide_past_events( $query ){
        if( $query->is_main_query() && 'event' == $query->get('post_type') ){
            $query->set('showpastevents',false);
        }
    }
    

    You can optionally apply this to venue / category archive pages only using is_tax().

    Also you can list past events using eo_get_events() – and using the appropriate ‘event_start_before’, ‘event_end_before’ attributes where appropriate etc.

    The examples on that page are hopefully sufficient to get you started, but if you get stuck feel free to use the forums – and I’ll probably add further examples too.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.