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
-
January 12, 2012 at 2:30 pm #13310
Seth
ParticipantOn my site I have custom loops in a few places that use tribe_get_events().
It seems that in a custom loop you can’t pull information from recurring events. Instead you get data from the original recurring event.
Some example functions that pull the wrong data are tribe_get_start_date() and tribe_get_end_date().
I think this is a known issue, but I’m wondering if I can get an ETA on how long it might take to get this working. Thanks!
January 13, 2012 at 8:44 am #13328Rob
MemberHey Seth. This is confirmed as an issue; we have it in the system as a 2.1 fix so we’re hoping to get something out over the next month or so. In the interim, though, let me see if one of our advanced devs can offer up a short-term solution (though no guarantees one exists yet).
January 13, 2012 at 12:27 pm #13346Seth
ParticipantYou guys are great, thanks!
January 13, 2012 at 7:02 pm #13364Rob
MemberThanks for the words 🙂 Happy to help. We’ll get you a response here ASAP.
January 19, 2012 at 10:29 am #13624Rob
MemberHey again Seth. Got one of our advanced devs to take a look here, and he’s sort of stumped…we’re not experiencing the same thing as you when using tribe_get_events(); we get all the recurring events we want, with their own date (like start date)(not that of the first event). Would you be able to share with us what you are passing as arguments into it? Thanks in advance.
January 19, 2012 at 11:01 am #13636Seth
ParticipantSure, I created a shortcode so I could display upcoming events on any page/post.
/* Upcoming events shortcode ****************************************************************/
function events_shortcode($atts) {
extract(shortcode_atts(array(
'category' => '',
'limit' => 4,
'display_city' => false
), $atts));$events = ''; // Will contain all of the events to display
global $wp_query;
$tribe_ecp = TribeEvents::instance();$old_display = $wp_query->get('eventDisplay');
$event_options = array(
'numResults' => $limit,
'tribe_events_cat' => $category,
'eventDisplay' => 'upcoming'
);$event = tribe_get_events( $event_options );
if(!$event[0]) {
$events .= 'There are no upcoming events at this time.';
} else {$counter = 1;
foreach($event as $e) :
if($counter % 2) { $events .= ''; }
$event_categories = get_the_terms( $e->ID, $tribe_ecp->get_event_taxonomy());$events .= '';
$events .= '';
$events .= tribe_get_start_date($e->ID, false, 'M').''.tribe_get_start_date($e->ID, false, "j");
$events .= '';
$events .= 'ID).'">'.get_the_title($e->ID).'';
$events .= '';
if(tribe_get_start_date($e->ID, false, 'g:i a') !== '12:00 am') {
$searchArray = array(":00", "am", "pm");
$replaceArray = array("", "a.m.", "p.m.");
$events .= str_replace($searchArray, $replaceArray,tribe_get_start_date($e->ID, false,'g:i a')) .' - ';
}
if(tribe_has_venue($e->ID)) {
$events .= tribe_get_venue($e->ID);
}
$events .= '';
if(tribe_get_city($e->ID) && $display_city) {
$events .= ''.tribe_get_city($e->ID).', '. tribe_get_state($e->ID).'';
}
$events .= '';
$counter++;
if($counter > $limit) { break; }
endforeach;
}
wp_reset_query();
$events .= '';
return $events;
}
add_shortcode('events', 'events_shortcode');January 19, 2012 at 11:04 am #13638Seth
ParticipantPasted a bit weird, here’s the same thing in pastebin – http://pastebin.com/ek5Uj3uD
February 1, 2012 at 11:21 am #14538Mike
ParticipantSeth – thankyou so much for this shortcode function! I’ve made immediate use of it!
February 1, 2012 at 11:33 am #14540Seth
ParticipantYou’re welcome. I never even thought of other people using it, since it’s customized to my own setup. 🙂
You’ve probably noticed but you can pass options into the shortcode like [events limit=”10″ category=”Category name”]
If you use recurring events on your site could you let me know if the dates for those work using this shortcode? The dates show up incorrectly on my site and I’ve been trying to fix it.
February 1, 2012 at 11:51 am #14541Mike
ParticipantIt needs styling, but it returned my upcoming events straight away without modifying anything 🙂
I did notice the parameters – great touch. Is it possible to include multiple categories? eg: [events category=”Competition,Clubs”]
I don’t use recurring events on my site, sorry.
February 1, 2012 at 11:57 am #14542Seth
ParticipantActually I think it should work with multiple categories just how you put it.
February 1, 2012 at 12:05 pm #14543Mike
ParticipantYou’re right – it does. Just tried it and it works.
I’ve requested your shortcode (or something very similar to it) be added to the core, because this is a function/feature that a lot of people would want to make use of.
February 1, 2012 at 8:26 pm #14565Rob
MemberJust made a note of this in the other thread too, but this is great. I’m going to have a dev comment over there if possible as to the reasoning behind excluding shortcodes in the core up until now.
February 22, 2012 at 11:35 am #15506Kris LaGreca
Participant@Seth, thanks for the code. It looks like something is wonky with the foreach loop that calls events. It causes the list that returns to be the same event (first entry called in the loop). See here: http://www.gainbridges.com/. I tried to debug it but I’m not having much luck.
When you get a chance, can you take a peek and see where the error is? We all appreciate your effort!
February 22, 2012 at 8:06 pm #15526Rob
Member@Seth: No pressure 🙂 But anything you can think of on this would surely help Kris (or anyone else who comes by with this problem down the road).
-
AuthorPosts
- The topic ‘Incorrect recurring event info from custom loop’ is closed to new replies.
