Home › Forums › Calendar Products › Events Calendar PRO › Past events — how to exclude them
- This topic has 12 replies, 4 voices, and was last updated 9 years, 6 months ago by
David.
-
AuthorPosts
-
August 22, 2016 at 8:13 pm #1154641
David
ParticipantHi,
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
DaveAugust 23, 2016 at 2:26 pm #1155038Nico
MemberHi 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,
NicoAugust 23, 2016 at 2:33 pm #1155044David
ParticipantThis reply is private.
August 25, 2016 at 9:04 am #1155839Nico
MemberThanks 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,
NicoAugust 25, 2016 at 11:15 am #1155963David
ParticipantHi 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?
August 26, 2016 at 2:59 pm #1156544Nico
MemberHey 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,
NicoAugust 26, 2016 at 3:05 pm #1156549David
ParticipantThis reply is private.
August 29, 2016 at 7:28 pm #1157370Nico
MemberThis reply is private.
August 30, 2016 at 4:42 pm #1157883Nico
MemberThis reply is private.
September 20, 2016 at 12:39 pm #1166605David
ParticipantThis reply is private.
September 22, 2016 at 8:04 am #1167385Nico
MemberThis reply is private.
October 14, 2016 at 9:35 am #1176612Support Droid
KeymasterHey 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 -
AuthorPosts
- The topic ‘Past events — how to exclude them’ is closed to new replies.
