Upcoming events function no longer works

WordPress Event Management, Calendars & Registration Forums General Question Upcoming events function no longer works

This topic contains 2 replies, has 2 voices, and was last updated by  Ronya Banks 9 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18023

    Hi, Stephen,

    Some time ago you gave me a function to use so that events with a specific tag (in this case,
    “Upcoming Events”) that were occurring now or later would display sorted by their start date in
    ascending order.

    With the update to Event Organiser (one of the updates past version 1.7, I believe), past events are
    now displaying and they are no longer sorting in order.

    Here’s the function: add_action( 'pre_get_posts', 'shahn1234_group_occurrences' );

    function shahn1234_group_occurrences( $query ){
    if( defined( 'EVENT_ORGANISER_DIR' ) && eventorganiser_is_event_query( $query )
    && $query->is_main_query()
    && is_tax( 'event-tag' ) ){

         $query->set( 'group_events_by', 'series' );
         $query->set( 'event_start_after', 'now' );
     }
    

    }

    The web page is http://www.ashevillemeditation.com/events/tag/upcoming-events

    Do you have any idea why this might be happening?

    Thanks,
    Suzanne

    Ronya Banks
    #18037

    Hi Suzanne,

    That snippet is still correct, so it should still work. Furthermore there haven’t been any changes to the relevant part of the codebase in over year. That doesn’t rule out a bug in the plugin but coupled with the fact this is a significant issue that hasn’t been previously reported I think the issue might be a conflict with another plugin.

    One thing I noticed is that the page doesn’t display any dates. This might bd relevant. Are you using a custom template?

    Stephen Harris
    #18354

    Hi, Stephen,

    I just want to update with the solution I found in case it’s useful to you or to anyone else.

    I checked theme and plugin conflicts but this did not resolve the problem. I was using a
    custom template so I tried reverting to your events/tags template, but the problem with dates
    no longer appearing, incorrect sort order, and past events displaying continued.

    I ended up adding the following line to the function I mentioned above, and it resolved everything:

    $query->set( 'post_type', array( 'event' ) );
    
    Ronya Banks
Viewing 3 posts - 1 through 3 (of 3 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.