Home › Forums › Calendar Products › Events Calendar PRO › show past events in calendar view
- This topic has 7 replies, 3 voices, and was last updated 9 years, 7 months ago by
Steven Trudell.
-
AuthorPosts
-
September 23, 2016 at 9:52 am #1168028
Steven Trudell
ParticipantWe want to have past events continue to show in calendar view.
I found a knowledge base article about how to hide past events … but inspecting the DOM shows that they simply aren’t there. We want them to be there ๐
We don’t see a setting for this. How do we achieve it?
September 23, 2016 at 2:47 pm #1168161Nico
MemberHi there Steven,
Thanks for getting in touch with us!
There’s actually no setting to do this, you’ll need to add the following snippet in your theme’s (or child theme’s) functions.php file to achieve this:
https://gist.github.com/elimn/d034dfddb9be206d9cc1#file-tribe_set_default_date-php
This code was suggested by Brook to another customer in this thread and seems to be what you are looking for.
Please let me know about it,
Best,
NicoSeptember 26, 2016 at 6:20 am #1168689Steven Trudell
ParticipantThanks, but that snippet:
1. Sets the default date to the past, which is not what we want, and
2. The past events still don’t display.
We want the calendar to still default to displaying the current month, day, etc. But we want past *events* to show up, no matter what view you are looking at.
So, if someone looks at September in month view, and there was an event on September 2, it should still be there, showing. You should be able to see it. But it isn’t; it just disappears. This snippet does not fix that?
September 27, 2016 at 12:05 pm #1169403Steven Trudell
ParticipantJust following up, can you help?
Does our request make sense? In the main, large calendar, we want all events to continue to show, even after they are in the past. (Just as they would not evaporate from a paper calendar – you might cross them out, but they would still be there.)
The snippet you provided previously did not cause that to happen.
How can we make that happen?
September 27, 2016 at 1:54 pm #1169491Nico
MemberHey Steven,
Thanks for following up and sorry for the delay in my reply!
We want the calendar to still default to displaying the current month, day, etc. But we want past *events* to show up, no matter what view you are looking at.
Let me clarify a bit on this, the snippet I sent will just work on list view (the code to make it work on other views is commented out) but please note that Month, Week and Day view already show past events in the corresponding time period, so there’s nothing we can change in those. The snippet might work for list, photo or map views (which I enabled in the amended code below):
/*
* Set the default date for views like List and Month
* Modify the $date variable below to set your date
*/
function tribe_set_default_date( $wp_query ) {
// Only run on main event queries
if ( ! tribe_is_event_query() || ! $wp_query->is_main_query() || $wp_query->get( 'eventDate' ) != '') return;
// Set this to the date you want shown, in YYYY-MM-DD format
$date = '2000-01-01';
// Select which TEC views you want this to apply to by uncommenting them
if (
tribe_is_list_view()
|| tribe_is_map()
|| tribe_is_photo()
// || tribe_is_month()
// || tribe_is_week()
// || tribe_is_day()
) {
$wp_query->set( 'eventDate', $date );
}
}
if ( function_exists('tribe_is_event_query') ) {
add_action( 'parse_query', 'tribe_set_default_date', 100);
}
If yo do not include the other snippet below this the date in the picker won’t be changed.
Important: please note the code sent is intended to be a starting point for the custom functionality you are trying to achieve, basically we do not support this feature and it’s probable you’ll need to tweak the code to fit your project needs. Sorry if I didn’t made this clear in the first place, but we cannot support features that aren’t actually part of the plugin!
Please let me know if the code is working for the enabled views now (list, photo and map), and also your thoughts about this,
Best,
NicoSeptember 28, 2016 at 6:14 am #1169733Steven Trudell
ParticipantPast events are showing, thanks!
September 28, 2016 at 6:20 am #1169737Nico
MemberYou are welcome Steven ๐
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,
Nico -
AuthorPosts
- The topic ‘show past events in calendar view’ is closed to new replies.
