Home › Forums › Calendar Products › Events Calendar PRO › Counting Posts Issue when Recurring events are introduced
- This topic has 2 replies, 2 voices, and was last updated 12 years, 2 months ago by
Barry.
-
AuthorPosts
-
January 28, 2014 at 9:33 am #97757
EJ Ulery
ParticipantHello,
I am having an issue with displaying only 3 posts when recurring events are introduced. I know this is not an issue with the plugin itself, but I have researched and asked other forums with no response. Below is what I have so far. I used the code in this thread (https://tri.be/support/forums/topic/reoccuring-event-shows-multiple-times-in-loop/) to display only one recurring event post, but the others are still counted by the incrementing operator. So if I have posts:
- A1 (recurring)
- A2 (second recurring)
- B
- C
I only want to display:
- A1
- B
- C
Since the incrementing operator is counting A2, I receive this result:
- A1
- B
<p>Here is my code. I’ve tested placing $event_count2++; in a number of different places without success. I should also note that in places where I do not need to limit the amount of events/posts shown, this script works beautifully.</p>
<p>I’ve removed all code that wasn’t pertinent to the issue. it has been replaced by “//description of what displays there”</p>
$event_count2 =1;
$args = array('post_type' =>'tribe_events');
$wp_query = null;
$wp_query = new WP_Query($args);
$postids = Array();
if($wp_query->have_posts() ) :
while ($wp_query->have_posts()) : $wp_query->the_post();
$Sub_Featured_post_event = get_post_meta($post->ID,'Sub_Featured_post',true);
if($event_count2<=3 && $Sub_Featured_post_event=='on'){
$recurring = get_post_meta($post->ID, '_EventRecurrence', true);
if ( $recurring ) {
$holdrecur = maybe_unserialize($recurring);
$ifrecur = $holdrecur['type'];
if ( $ifrecur == 'None' ) {
//NON-RECURRING EVENTS, SET AS NONE IN db.
$event_count2++;
}else{
/********** HERE IS WHERE THE ISSUE LIES ************/
$thisid = get_the_ID();
if ( !in_array($thisid, $postids)) {
array_push($postids, $thisid );
//RECURRING EVENTS
$event_count2++;
}
/********** END TROUBLESOME CODE ************/
}
}else{
//NON-RECURRING EVENTS, NOTHING IN DATABASE
$event_count2++;
}
}
endwhile;
endif;
wp_reset_query();
January 29, 2014 at 10:56 am #98347Barry
MemberIt’s great to see interesting stuff being built – but the code by Marty (and it was great of him to share it) is his code, it isn’t something we wrote and we can’t support it and troubleshoot it for you. Is using tribe_get_events() – which is effectively an event-friendly wrapper around WP_Query – an option here, setting the tribeHideRecurrence property to 1?
February 12, 2014 at 2:23 pm #103888Barry
MemberIt’s been a while so I’ll go ahead and close the thread. Of course if we can help with anything else please do go ahead and create a new one. Thanks!
-
AuthorPosts
- The topic ‘Counting Posts Issue when Recurring events are introduced’ is closed to new replies.
