Home › Forums › Calendar Products › Events Calendar PRO › Remove Event From View on Start Date
- This topic has 0 replies, 3 voices, and was last updated 8 years ago by
AJ Vargas.
-
AuthorPosts
-
February 28, 2018 at 1:18 pm #1466479
AJ Vargas
ParticipantCurrently events display until the end date of the event, but I would like for the display to end at the start date. Is there a way to make this change?
March 1, 2018 at 9:24 am #1467413Jaime Marchwinski
KeymasterHi AJ,
Thanks so much for reaching out!
The following snippet can shows the event for the first day and remove it from the rest in a multi-day event:
https://gist.github.com/vicskf/5854eb1f88b8886c39743ca250a4ba99
Let me know if this helps!
Thanks,
Jaime
March 19, 2018 at 11:34 am #1483242AJ Vargas
ParticipantThank you for that information, but that did not fix the issue I am trying to address. I have attached a screen shot. As you can see the two events published are still showing on the calendar even though they have started. I would like them to automatically drop off the display on the start date. I would only like to display events that can still be registered for.
March 21, 2018 at 3:31 pm #1485454Barry
MemberHi AJ,
I think I understand what you mean.
It’s worth noting that the calendar purposefully does not do this by default and, to that end, making it happen would require some small amount of custom code to be put in place.
In general we’re limited as to how far we can go with requests like that, but I’d be happy to offer you a possible starting point:
add_filter( 'posts_where', function( $sql, $query ) { global $wpdb; if ( 'list' !== $query->get( 'eventDisplay' ) ) { return $sql; } $start_field = "{$wpdb->postmeta}.meta_value"; $start_date = esc_sql( $query->get( 'start_date' ) ); return "$sql AND $start_field > '$start_date' "; }, 1000, 2 );The above snippet could be added either to a custom plugin (preferred) or else to your theme’s functions.php file and should do what you want, but note that:
- It only targets the upcoming list view
- It is not extensively tested, so I’d recommend some testing before rolling out on your live site
I hope that helps 🙂
April 12, 2018 at 9:35 am #1505720Support 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 ‘Remove Event From View on Start Date’ is closed to new replies.
