Home › Forums › Calendar Products › Events Calendar PRO › Incorrect recurring event info from custom loop
- This topic has 20 replies, 4 voices, and was last updated 14 years, 1 month ago by
Seth.
-
AuthorPosts
-
February 23, 2012 at 6:43 am #15548
Seth
ParticipantThis problem goes back to my original post. In these custom loops there are errors with recurring events. I believe because some of the functions don’t allow an ID from an instance of a recurring event.
For example if you call tribe_get_start_date($ID, false, ‘M’) on a recurring event you will get the month of the original.
If I look at the function tribe_get_start_date there are comments before it that confirm this:
/**
* Start Date
*
* Returns the event start date and time
*
* @param int $postId (optional) This only works for non recurring events
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @return string Date
* @todo support $postId for recurring events.
* @since 2.0
*/February 23, 2012 at 6:46 am #15549Seth
ParticipantI’m still looking for a solution to this myself. I have broken events showing up on a few of my pages because of this. For example on this page, http://www.dmu.edu/cme/, in the “Regular Scheduled Series” section they all say “May 26” which is the date of the original event and not the next upcoming date.
February 23, 2012 at 10:01 am #15569Rob
MemberHey Seth. I’m wondering if this might be fixed in the 2.0.4 code; since we’ve been unable to recreate so far I can’t guarantee it, but if you want to give that a go (either by emailing me for it early or waiting until it’s released later this afternoon) and let me know if the issue persists, we can take another look to see if we can identify any problems from there.
February 23, 2012 at 7:08 pm #15613Kris LaGreca
ParticipantI can confirm that the issue still exists in 2.0.4. Let me know if I can be of any help or test anything out.
February 24, 2012 at 7:52 am #15626Seth
ParticipantIt seems as if the date functions don’t work when passed a recurring event post ID if called from functions.php or a custom plugin. However, the same code works when I pass a recurring event post ID to tribe_get_start_date() in a page template like front-page.php. Could it be something with how the post is set up that is not able to happen in functions.php?
This baffles me further because both in the source code and the documentation it still states that the date functions are not supposed to work with recurring event post IDs, so I’m not sure why it’s working on my front-page.php.
For the time being, I realized that the permalink for each recurring event has the correct starting date in it. So I hacked together some code to retrieve the correct date from the permalink. I realize that this is definitely not the best way to do it, but until tribe_get_start_date() and tribe_get_end_date() are able to accept recurring post IDs I don’t see any other way.
if(tribe_is_recurring_event($post->ID)) {
$event_link = get_permalink($post->ID);
$event_date = strtotime(substr($event_link, $event_link.length-10, 10));
} else {
$event_date = tribe_get_start_date();
}February 24, 2012 at 8:04 am #15627Seth
ParticipantSmall correction with the else statement:
} else {
$event_date = strtotime(tribe_get_start_date());
}But like I said, this is a poor hack and hopefully not a long term solution 🙂
-
AuthorPosts
- The topic ‘Incorrect recurring event info from custom loop’ is closed to new replies.
