Incorrect recurring event info from custom loop

Home Forums Calendar Products Events Calendar PRO Incorrect recurring event info from custom loop

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #13310
    Seth
    Participant

    On 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!

    #13328
    Rob
    Member

    Hey 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).

    #13346
    Seth
    Participant

    You guys are great, thanks!

    #13364
    Rob
    Member

    Thanks for the words 🙂 Happy to help. We’ll get you a response here ASAP.

    #13624
    Rob
    Member

    Hey 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.

    #13636
    Seth
    Participant

    Sure, 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');

    #13638
    Seth
    Participant

    Pasted a bit weird, here’s the same thing in pastebin – http://pastebin.com/ek5Uj3uD

    #14538
    Mike
    Participant

    Seth – thankyou so much for this shortcode function! I’ve made immediate use of it!

    #14540
    Seth
    Participant

    You’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.

    #14541
    Mike
    Participant

    It 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.

    #14542
    Seth
    Participant

    Actually I think it should work with multiple categories just how you put it.

    #14543
    Mike
    Participant

    You’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.

    Incorrect recurring event info from custom loop

    #14565
    Rob
    Member

    Just 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.

    #15506
    Kris 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!

    #15526
    Rob
    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).

Viewing 15 posts - 1 through 15 (of 21 total)
  • The topic ‘Incorrect recurring event info from custom loop’ is closed to new replies.