Home › Forums › Calendar Products › Events Calendar PRO › Recurring Event Occurrences List
- This topic has 17 replies, 4 voices, and was last updated 10 years, 1 month ago by
Support Droid.
-
AuthorPosts
-
November 24, 2015 at 10:31 am #1030286
inhouse
ParticipantHi, I’ve been trying to figure out how to list all occurrences of an event in the list view and also on the single-event page. We used to use custom fields to display recurring event data before the plugin supported recurring events with different times and now that this great feature has been added, we’d like to take full advantage.
I looked at the singe-event template in the /view folder and found tribe_events_event_schedule_details however, this is only returning a single occurrence rather than a list of all occurrences. For instance, the event date is 1-14-16 but I’m only seeing the occurrence on 1-16-16. Is there a better function to use to accomplish this?
The events have a date and time set along with another ‘Custom’ recurrence rule:
Custom and will end on [different date]
Frequency Daily Every 1 DaysThanks in advance for any help!
November 24, 2015 at 2:58 pm #1030417Barry
MemberHi @inhouse,
Thanks for posting!
I have to be upfront and make it clear our support for customizations is fairly limited, but I’d be happy to try and steer you in the right direction if I can.
Here’s a starting point you might add to a custom plugin or even to your theme’s functions.php file:
function add_recurring_event_dates() { global $wpdb; // If it's not a recurring event we don't care if ( ! tribe_is_recurring_event() ) return; $current_event = get_the_ID(); $parent_event = get_post_field( 'post_parent', $current_event ); $root_event = ( 0 === $parent_event ) ? $current_event : $parent_event; // It would be nice to use tribe_get_events() or a WP_Query here, but results may // not be consistent due to recurrence_collapse_sql() logic amongst other things $instances = $wpdb->get_col( $wpdb->prepare( " SELECT ID FROM $wpdb->posts WHERE post_parent = %d ", $root_event ) ); if ( empty( $instances ) ) return; echo 'All dates: '; $dates = array_map( 'tribe_get_start_date', $instances ); echo implode( ',', $dates ); } add_action( 'tribe_events_after_the_meta', 'add_recurring_event_dates' ); add_action( 'tribe_events_single_event_after_the_meta', 'add_recurring_event_dates' );I would stress it is just a starting point and nothing more, there are many improvements and tweaks you could make not only in terms of formatting but in controlling where this is exposed — but perhaps it will be enough to get you headed in the right direction?
November 25, 2015 at 6:24 am #1030780inhouse
ParticipantHi @Barry and thanks for your help! The function isn’t working quite right. It’s returning extra dates. It’s returning today’s date and time mixed in with 1 legit date. I was getting only 1 date when I tried using tribe_events_event_schedule_details.
Instead of:
- December 4 at 6:45 PM
- December 5 at 7:30 PM
It’s returning:
- November 25 @ 9:18 am
- November 25 @ 9:18 am
- November 25 @ 9:18 am
- December 5 @ 7:30 pm
- November 25 @ 9:18 am
November 25, 2015 at 6:28 am #1030784inhouse
ParticipantThis reply is private.
November 25, 2015 at 7:14 am #1030813Barry
MemberHi @inhouse,
It’s returning extra dates. It’s returning today’s date and time mixed in with 1 legit date. I was getting only 1 date when I tried using
That’s odd, particularly the fact that you are seeing today’s date repeatedly. Without knowing exactly what’s in your database it’s hard to say exactly, but here is a revised version of the function:
https://gist.github.com/anonymous/4dc500f657b858244dff
I’ll reply to your private question in a separate post 🙂
November 25, 2015 at 7:23 am #1030821Barry
MemberThis reply is private.
November 25, 2015 at 8:39 am #1030858inhouse
Participant@Barry this is working great! I made a couple minor modifications so that it works for non-recurring events and my markup but overall this is exactly what was needed. Thanks again!
November 25, 2015 at 9:17 am #1030873Barry
MemberMy pleasure 🙂
I’ll go ahead and close this topic – but of course if anything else crops up please don’t hesitate to post new issues as needed.
Thanks again!
November 29, 2015 at 7:48 am #1032100Brian
MemberPer a customer request I have reopened this thread.
November 30, 2015 at 6:00 am #1032342inhouse
ParticipantThanks for re-opening @Brian. @Barry I spoke too soon last week when I said this was working perfectly. I realized that this is working for events which have 2 occurrences (only 1 recurrence rule) but if there are 2 or more recurrence rules the dates are out of order and duplicated. The same scenario is true of event detail pages and the list view.
I’m posting screenshots of my event schedule details in case there’s anything wrong there but the fact that the dates are out of order seems more to do with the function or even a plugin bug but I have no idea. If you have anything you want me to test, let me know. Thanks again!
Example event recurrence settings:
https://www.dropbox.com/s/ejatn6swwfrz4qe/Screenshot%202015-11-30%2008.54.26.png?dl=0Example event display:
- December 20
- December 19
- December 20
- December 18
- December 19
November 30, 2015 at 8:04 am #1032641Barry
MemberHi @inhouse,
I don’t think this is a bug in The Events Calendar/Events Calendar PRO as such, it’s just that the snippet I provided was a fairly simple one that doesn’t cater to more complicated use cases.
As highlighted earlier in the exchange, the amount of support we can provide for custom dev tasks like this one is rather limited — so, in general, please see snippets like these as a starting point for you to build on and polish rather than a complete and finished solution 🙂
At any rate, here’s a revised and updated version of the snippet:
https://gist.github.com/barryhughes/cfe57641000da38ca249
I hope that helps!
November 30, 2015 at 8:43 am #1032671inhouse
ParticipantThanks @Barry but this is still not displaying the dates correctly. There seem to be in between dates showing up for some reason. Can you confirm we’re entering event recurrences correctly (see screenshot and typed example below)? The verbiage “Recurrence Rules: ‘Custom’ and will end ‘On’…” is confusing to me. Could the plugin or function be displaying all custom field data even if it was since ‘deleted’? I’ve seen this type of thing while working with custom fields for other projects.
Desired occurrences:
- December 18 AT 7:30 pm
- December 20 AT 2:00 pm
- December 20 AT 7:30 pm
Currently displaying:
- December 18 AT 7:30 pm
- December 19 AT 2:00 pm
- December 19 AT 7:30 pm
- December 20 AT 2:00 pm
- December 20 AT 7:30 pm
-
This reply was modified 10 years, 4 months ago by
inhouse. Reason: Added an idea
November 30, 2015 at 11:42 am #1032767Barry
MemberHi @inhouse,
Unfortunately, it may be this is a bug in Events Calendar PRO after all.
Your recurrence rules should indeed result in three events (one on the 18th and two on the 20th) because of your exclusion rule for the 19th … however, it seems that isn’t actually being respected.
I misinterpreted your previous post to suggest the extra dates were somehow only creeping in via the snippet – but on trying to replicate the problem with the very same rules, it seems to me that it is nothing to do with the snippet as such (which is simply picking up on the events that have been generated). Rather the problem is that the exclusion rule is being ignored and those events on the 19th are still being created.
We have had a few problems with custom exclusions and many of those issues will be ironed out in our next few releases – but I’ll be sure to check that this is amongst them (and we’ll update this topic as soon as a fix for this is released).
Thanks again for your patience.
November 30, 2015 at 11:48 am #1032768inhouse
ParticipantAh, ok. I’ll have to roll our templates back to the previous versions to get dates displaying ‘properly’ again until the next update. I really appreciate your continued support on this! Will I be notified of a new update via this thread (email notification)? And not to be impatient at all but would you estimate days, weeks or months for the update?
November 30, 2015 at 12:13 pm #1032774Barry
MemberIf you’ve checked the notify me of follow-ups by email box then yep, you should get an alert each time we update this topic (and if you haven’t, feel free to reply again and do so then) 🙂
In terms of timelines I’m afraid I can’t offer any guarantees there – we’re literally discussing this right now and so don’t have a firm idea just yet. What I can say is it is very unlikely to be the very next release – since that is in code freeze (we’re in the final stages of preparation before release).
We do hope to follow up shortly after that with a further maintenance release and if we can roll this in there we’ll do so, but again that isn’t a certainty. Perhaps in the interim – though I appreciate it isn’t ideal – you could create events without exclusions, then manually remove the ones you don’t want by trashing them via the main events admin list?
-
AuthorPosts
- The topic ‘Recurring Event Occurrences List’ is closed to new replies.
