Display only current/upcoming week in list/map view

Home Forums Calendar Products Events Calendar PRO Display only current/upcoming week in list/map view

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1002617
    Yann
    Participant

    Hello,
    I’m a new user of the PRO version of the Events Calendar.
    I’m trying to wrap everything up to make the plugin look like I want it to.
    Only thing I don’t find is in map view : how to display only the events of the current and/or upcoming week ( and that’s it, no further events displayed ). I read many things about the tribe_get_events but nowhere I found out which parameters to pass. I mean not a beginning and end date, but really the current / next week events.
    Is there some trick ?
    Thanks a lot.

    #1002712
    Nico
    Member

    Howdy Yann,

    Welcome to our support forums and thanks for reaching out to us!

    I think the best way to tweak this would be to modify the query before it get’s the posts. This snippet will surely get you on the right path:


    add_action( 'tribe_events_pre_get_posts', 'upcoming_two_weeks' );
    function upcoming_two_weeks( $query ) {

    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && $query->get('eventDisplay') == 'map' ) {

    $end_time = strtotime('+2 weeks');
    $end_date = date("Y-m-d G:i:s", $end_time);

    $query->query_vars['meta_query'][] = array('key' => '_EventStartDate', 'type' => 'DATETIME', 'compare' => '<', 'value' => $end_date);
    }

    return $query;
    }

    Add this code to your functions.php file -located at wp-content/themes/your_theme/- and you should see Map view upcoming events limited to two weeks from the current date. Haven’t fully tested it, but seems to work fine!

    Please let me know if you can implement this fix,
    Best,
    Nico

    #1002782
    Yann
    Participant

    Hello Nico, thanki you for lightning quick answer and welcome message. I implemented your snippet and it works like a charm ! Huge thanks, I can finally CSS my calendar now ! Thanks a lot, have a nice day.

    #1002839
    Nico
    Member

    Hey Yann,

    Glad I could help you out on this 🙂

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best of luck with your project,
    Nico

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Display only current/upcoming week in list/map view’ is closed to new replies.