Home › Forums › Calendar Products › Events Calendar PRO › Reoccuring event shows multiple times in loop
- This topic has 29 replies, 9 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
February 24, 2012 at 1:57 pm #15677
Michael
ParticipantCode: 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 eventsFebruary 27, 2012 at 10:20 am #15718Jonah
ParticipantHey 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,
JonahMarch 5, 2012 at 4:53 am #16197moderntribe
ParticipantHi, 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?
March 5, 2012 at 11:42 am #16223Michael
ParticipantHey 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”.
March 6, 2012 at 7:01 am #16277moderntribe
ParticipantUnfortunately 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! :-\
April 11, 2012 at 12:54 pm #17826Cliff
ParticipantI’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.
April 11, 2012 at 12:56 pm #17827Cliff
ParticipantWell, the backticks were supposed to indicate code, so sorry—no indentation was kept. I hope that still makes sense.
April 11, 2012 at 3:58 pm #17828Jonah
ParticipantHey Cliff, if you use
tags, it should work, otherwise you can post on some external service like Postie, Gist or Pastebin.Thanks,
JonahApril 11, 2012 at 3:59 pm #17829Jonah
ParticipantI meant code tags…
April 12, 2012 at 7:22 am #17850Cliff
ParticipantHaha, I know now! I didn’t see any instructions one way or another, and this was my first post. Apologies.
April 12, 2012 at 9:58 am #17854Rob
MemberThanks 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.
April 16, 2012 at 7:30 am #17935Cliff
ParticipantHey 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.
April 16, 2012 at 5:36 pm #17959Rob
MemberExcellent to hear. Thanks for confirming, Cliff.
April 24, 2012 at 1:06 pm #18245Marty
Participant@Cliff I’m looking to do this same thing. Would you able to post a snippet of the conditions you created? Cheers
April 25, 2012 at 12:28 pm #18273Marty
ParticipantI 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;
-
AuthorPosts
- The topic ‘Reoccuring event shows multiple times in loop’ is closed to new replies.
