Past events — how to exclude them

Home Forums Calendar Products Events Calendar PRO Past events — how to exclude them

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1154641
    David
    Participant

    Hi,

    I looked around for a way to fix this but am not finding anything.

    Our Event Calendar is showing a “Previous Events” link on the bottom of our first page of events, which, when clicked, shows events that are over.

    We don’t want visitors to see the past events, but want to keep them in the back end. Is there a way to only have it show future events and, ideally, not display the link to previous events until we’re on page 2 of the future events listings, but still have the past event viewable in the admin?

    Thanks
    Dave

    #1155038
    Nico
    Member

    Hi Dave,

    Thanks for reaching out to us on this! I can help you here…

    Is there a way to only have it show future events and, ideally, not display the link to previous events until we’re on page 2 of the future events listings, but still have the past event viewable in the admin?

    So, you want to hide past events from the site I get that he, but I’m not sure about what you mention regarding the previous events link, to show only in page 2. You mean that if the user is in the future he/she should be able to paginate to more recent upcoming events, but never see the ones before today?

    Please let me know about it and I’ll create a snippet to get those out of the site if possible,
    Best,
    Nico

    #1155044
    David
    Participant

    This reply is private.

    #1155839
    Nico
    Member

    Thanks for following up Dave, I get you now πŸ™‚

    Can you try with this snippet (from a past thread):

    /* Tribe hide past events in the frontend */

    add_filter('tribe_events_pre_get_posts', 'filter_tribe_all_occurences', 100);

    function filter_tribe_all_occurences ($wp_query) {
    if ( !is_admin() ) {
    $new_meta = array();
    $today = new DateTime();

    // Join with existing meta_query
    if(is_array($wp_query->meta_query)) {
    $new_meta = $wp_query->meta_query;
    }

    // Add new meta_query, select events ending from now forward
    $new_meta[] = array(
    'key' => '_EventEndDate',
    'type' => 'DATETIME',
    'compare' => '>=',
    'value' => $today->format('Y-m-d H:i:s')
    );

    $wp_query->set( 'meta_query', $new_meta );
    }
    return $wp_query;
    }

    Please let me know if it works for you,
    Best,
    Nico

    #1155963
    David
    Participant

    Hi Nico, this didn’t work unfortunately. πŸ™

    I’ve set the past event to ‘Draft’ which alleviates the problem. How about this — is there a way to automagically set events that are over to ‘Draft’ rather than having to go in and do it manually?

    #1156544
    Nico
    Member

    Hey Dave,

    Sorry to hear this didn’t work for you πŸ™

    I tested it in my local test site and it works as expected. Can you test this with default theme making sure you move the snippet to the correct functions file?

    I think the suggested solution is better than the draft option which will surely be more complicated to instrument.

    Please give this a try with default theme and let me know if it works in that scenario,
    Thanks,
    Nico

    #1156549
    David
    Participant

    This reply is private.

    #1157370
    Nico
    Member

    This reply is private.

    #1157883
    Nico
    Member

    This reply is private.

    #1166605
    David
    Participant

    This reply is private.

    #1167385
    Nico
    Member

    This reply is private.

    #1176612
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Past events — how to exclude them’ is closed to new replies.