Countdown widget not skipping to next event

Home Forums Calendar Products Events Calendar PRO Countdown widget not skipping to next event

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1156950
    Riccardo
    Participant

    Hi there guys, I have just realised that the countdown widget is not skipping to next upcoming event. Once the events is reached, it will show “No upcoming events!”….
    Is this by design?

    #1156998
    Riccardo
    Participant

    I have fixed the problem creating a custom shortcode, however I’d like to understand why the widget won’t work as (I) expected. It should be that once the event is expired it will skip to the next upcoming automatically, otherwise users are forced to manually update the widget… crazy!

    Now,as stated here function tribe_get_events will return also events started earlier than the supplied date, I had to loop in the next (6 for me) events to verify if the start date is equal or greater than the requested start date.

    Seems strange to me really, both the widget behaviour and the tribe_get_events …..

    function my_event_countdown($atts, $content = null) {
            $date = new DateTime('tomorrow');
            $result = $date->format('Y-m-d H:i:s');
            $events = tribe_get_events( array(
             'eventDisplay' => 'list',
             'posts_per_page' => 6,
             'start_date' => date( $result )
             ) );
       
            foreach ( $events as $post ) {
                setup_postdata( $post );
                if(substr($post->EventStartDate,0,10) >= substr($result,0,10 )) {
                    break;
                }   
            
            }
            $a = '[tribe_event_countdown id="'.$post->ID.'"]';
    
            return do_shortcode($a);
    }
    
    add_shortcode( 'next_countdown','my_event_countdown');
    • This reply was modified 9 years, 8 months ago by Riccardo.
    #1157345
    Andras
    Keymaster

    Hello Riccardo,

    Thank you for posting your solution!

    How the plugin actually works is that it counts down, and once it reaches the event it shows the message <u>until the end time of the event</u>.
    Once the event is over, it will automatically show the next event.

    I hope this explains.

    Cheers,
    Andras

    #1157485
    Riccardo
    Participant

    Thanks for clarifying Andras. The behaviour is not useful in my case because once the event begin date is expired it should be more relevant to immediately show the next upcoming.

    Cheers! 🙂

    #1157675
    Andras
    Keymaster

    Hey Riccardo,

    Thanks for your feedback! I totally understand there are situations where showing the next event immediately is needed. Good job on the code!

    Since this is marked resolved I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.

    Cheers,
    Andras

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Countdown widget not skipping to next event’ is closed to new replies.