Straight Event List

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11404

    How can I output a straight list of events like posts (without the request query vars)?

    My problem is if I have a single event which recurs every month for a year, the event list shows all the repeats.

    If I group occurrences then it will only show the first one (january), which is no good if we are half way through the year, and recurring events which have past still appear in the archive.

    I have been trying to output a straight list of the events ( like the admin list ) but the query vars always interfere and I cant find any way to alter them with pre_get_posts, post_request or any other filter..pulling my hair out!!

    Mark Piranha
    #11405

    Hi Mark,

    If you group occurrences, it actually shows the earliest date matching the query. As such, if you opt to not include past events in the plug-in settings (there are separate options for widgets/shortcodes) and group occurrences, you should see the next date.

    Stephen Harris
    #11407

    Ah right ok, it doesn’t quite work when you view the archive for the current month…if I have a recurring event every Monday, and view the archive for that month halfway through (the month), with no past events and grouped occurrences, it only shows the entry for the first Monday.

    Mark Piranha
    #11408

    On the month archive, the ‘don’t show past events’ is ignored, and all events that month are shown (regardless of whether they are ‘past’ or not). This was done to address buggy-behaviour associated with the widget calendar: https://github.com/stephenharris/Event-Organiser/issues/30

    You could either, ‘ungroup’ events for day/month/year archives:

    function myprefix_dont_group_events_archive( $query ){
        if( $query->is_main_query() && eventorganiser_is_event_query( $query ) ){
            if( eo_is_event_archive( 'day' ) || eo_is_event_archive( 'month' ) || eo_is_event_archive( 'year' ) ){
                    $query->set( 'group_events_by', 'occurrence' );  
            }
        }   
    }
    add_action( 'pre_get_posts', 'myprefix_dont_group_events_archive', 15 );

    Or perhaps alter the event_start_after (hook onto pre_get_posts with priority higher than 10). and change it so that it’s set to the start of day/month/year or today (whichever is later).

     $current = $query->get( 'event_start_after' );
     $now     = new DateTime( 'now', eo_get_blog_timezone() );
     $event_start_after = ( $current > $now ? $current : $now );
     $query->set( 'event_start_after', $event_start_after );
    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 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.