Reoccuring event shows multiple times in loop

Home Forums Calendar Products Events Calendar PRO Reoccuring event shows multiple times in loop

Viewing 15 posts - 1 through 15 (of 30 total)
  • Author
    Posts
  • #15677
    Michael
    Participant

    Code: http://tinypaste.com/cc1fbc72
    Result: Shows a steam of recent posts and every single reoccurrence of each event.
    Desired Result: Show a stream of recent created posts and events

    #15718
    Jonah
    Participant

    Hey Michael,

    First off I just wanted to point out that you probably don’t want to use is_post_type anymore. It’s deprecated – see: http://codex.wordpress.org/Conditional_Tags#A_Post_Type

    Now, to address the issue at hand… This does appear to be a problem – I’m seeing the same thing with my recurring events, the links are all linking to the one event. I’m not sure if this is by design or if it’s an issue…

    I’m going to need to have another dev jump in and take a look. We’ll be in touch.

    Regards,
    Jonah

    #16197
    moderntribe
    Participant

    Hi, Michael.

    Is the issue that the recurring events are linking to a single event? Or is the problem that it is showing every instance of recurring events, when you want it only to show one instance?

    #16223
    Michael
    Participant

    Hey Paul,

    Confirming that its the latter case: “the problem that it is showing every instance of recurring events, when you want it only to show one instance”.

    #16277
    moderntribe
    Participant

    Unfortunately there is not a good way to hide all but one instance of a recurring event; they all are recognized as separate events. You should at least be able to limit the number of posts returned (so you don’t have a list of hundreds of events, if that is how many recurrences there are) by using the posts_per_page attribute in your query. Not sure if that helps to solve your problem at all. Sorry I couldn’t be of more help! :-\

    #17826
    Cliff
    Participant

    I’m not sure if this is helpful, but I’ve found a way to detect if an event is recurring or not. The variable $recurring will be empty if the event is a one-time event. The meta field _EventRecurrence holds the serialized data on recurrence, so:

    `$recurring = get_post_meta($post->ID, ‘_EventRecurrence’, true);
    if ( $recurring ) {
    $holdrecur = maybe_unserialize($recurring);
    $ifrecur = $holdrecur[‘type’];
    if ( $ifrecur == ‘None’ ) {
    $recurring = ”;
    }
    }`

    Mostly, there’s no entry in the database for a one-time event, so $recurring will be empty. Sometimes, though, it inserts a row explicitly saying there’s no recurrence. We check for that by using WP’s native unserialize, then find the ‘type’. If it’s set to ‘None’, we’ll reset $recurring to empty.

    #17827
    Cliff
    Participant

    Well, the backticks were supposed to indicate code, so sorry—no indentation was kept. I hope that still makes sense.

    #17828
    Jonah
    Participant

    Hey Cliff, if you use tags, it should work, otherwise you can post on some external service like Postie, Gist or Pastebin.

    Thanks,
    Jonah

    #17829
    Jonah
    Participant

    I meant code tags…

    #17850
    Cliff
    Participant

    Haha, I know now! I didn’t see any instructions one way or another, and this was my first post. Apologies.

    #17854
    Rob
    Member

    Thanks Jonah!

    Cliff, you all set here? Let us know if you’re still having issues after giving Jonah’s suggestion a go and we’ll do what we can to assist from there.

    #17935
    Cliff
    Participant

    Hey Rob. I think I’m good—just wrote some conditions expanding on the above to only show recurring events once when using them in a loop. It might be useful for a future native filter of some type, but seems beyond the scope of this thread.

    #17959
    Rob
    Member

    Excellent to hear. Thanks for confirming, Cliff.

    #18245
    Marty
    Participant

    @Cliff I’m looking to do this same thing. Would you able to post a snippet of the conditions you created? Cheers

    #18273
    Marty
    Participant

    I found it was really easy to detect recurring events via the post ID. I added post IDs to an array and then checked against it, as follows:


    $postids = Array();
    while ( have_posts() ) : the_post();
    $thisid = get_the_ID();
    if ( !in_array($thisid, $postids)) :
    array_push($postids, $thisid );
    // Output the post
    endif;
    endwhile;

Viewing 15 posts - 1 through 15 (of 30 total)
  • The topic ‘Reoccuring event shows multiple times in loop’ is closed to new replies.