Home › Forums › Calendar Products › Events Calendar PRO › tribe_get_events query returns past recurring events
- This topic has 9 replies, 2 voices, and was last updated 10 years, 4 months ago by
Brian.
-
AuthorPosts
-
January 15, 2016 at 11:05 am #1056756
Admin
ParticipantI have a relatively simple query that returns 3 current day events. It works fine except for recurring events. I have a weekly recurring event and the first instance of that recurring events always appears at the top of the results list. The site in question is under development and password protected so I cannot send a link, but please see my code below. The screenshot was taken today, January 15th and shows the weekly recurring event that began on 1/12 along with two correct events that are scheduled for today. I hope you can suggest a fix. Thanks!
Screenshot:
$start_date = date("Y-m-d"); $end_date = date("Y-m-d", strtotime("+1 day")); $events = tribe_get_events( array( 'posts_per_page' => 3, 'eventDisplay' => 'custom', 'start_date' => $start_date, 'end_date' => $end_date, ) );January 15, 2016 at 1:21 pm #1056810Brian
MemberHi,
Thanks for using our plugins. I can help out here.
Try adding this to your query:
'tribeHideRecurrence' => true,That should prevent recurring events from being included.
Does that work?
January 15, 2016 at 1:59 pm #1056828Admin
ParticipantThanks for your reply. I had tried that already without success. My updated query with your suggestion had no affect – the past recurring event is still being displayed.
$events = tribe_get_events( array( 'posts_per_page' => 3, 'eventDisplay' => 'custom', 'start_date' => $start_date, 'end_date' => $end_date, 'tribeHideRecurrence' => true, ) );January 18, 2016 at 7:56 am #1057872Brian
MemberHi,
What is the settings for the recurring event that is show? Does if have a instance on the 15th when you took that image?
Is it still showing that one today?
I tried to reproduce on my test site with a recurring event before today and it worked correctly for me and did not show.
I can try to help out some more, but I am limited in troubleshooting customizations.
Let me know though about your recurring event and I will test it out again.
Thanks
January 18, 2016 at 8:30 am #1057915Admin
ParticipantHi Brian,
Thanks again for your help with this. I have attached a new screenshot showing the settings for the recurring event. The event started on January 12th, recurring weekly. So no, it did not have an instance on the 15th.And yes, it is still showing the first instance (1/12) today.
Hopefully the screenshot of the event settings may help.
January 18, 2016 at 3:48 pm #1058139Brian
MemberOk, I tried again and it did not pick up my recurring event so not sure why it is for you.
Does this happen on a specific page? Can you try another?
I can try to help out some more, but I am limited in troubleshooting customizations.
Let me know though.
January 18, 2016 at 4:33 pm #1058180Admin
ParticipantHi Brian,
Well, I’m at a loss too. I’ve really got to get this working because it was really the only reason we purchased the Pro version of the events calendar – for the recurring events.So I created a stripped down page template for testing. You will need to enter a username and password to see the front end pages. First go to the home page
http://frostscience.wpengine.com/
u: frostscience
p: 08336c16Then go to this link: http://frostscience.wpengine.com/recurring-event-test/
You will see the past recurring event as the first result “Jan 12, Social Event – Recurring”.
In my query I used ‘tribeHideRecurrence’ => true, which successfully turns off all other instances of the recurring event except for the first one. I will paste the full code from this page below:<?php /** * Template Name: Recurring Event Test * * @package frost */ get_header(); ?> <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <?php $start_date = date("Y-m-d", strtotime("+1 day")); $end_date = date("Y-m-d", strtotime("+365 day")); $events = tribe_get_events( array( 'posts_per_page' => 10, 'eventDisplay' => 'custom', 'start_date' => $start_date, 'end_date' => $end_date, 'tribeHideRecurrence' => true, ) ); foreach ( $events as $post ) : setup_postdata( $post ); ?> <div> <?php echo tribe_get_start_date( $post->ID, false, 'M j, ' ); ?> <?php echo $post->post_title; ?> </div> <?php endforeach; wp_reset_postdata(); ?> </div> </div> </div> <?php get_footer(); ?>January 18, 2016 at 4:52 pm #1058195Brian
MemberHi,
Thanks for that.
I think I maybe have found the issue.
This event:
Social Event – Recurring
Has a start date of January 12 and the end date February 12
So set that way it is considered one long event for every day in between those dates, so it will always show first as the query considers it on going.
That event should instead be setup with the start and end date as the same date and then it is repeated daily until the 12th.
Like this:
Thanks
January 19, 2016 at 5:57 am #1058414Admin
ParticipantThat was it! The query is now working correctly. Thanks for your help!
January 19, 2016 at 6:11 am #1058622Brian
MemberGreat, glad it helps, I am going to go ahead and close this ticket, but if you need help on this or something else please post a new ticket.
Thanks!
-
AuthorPosts
- The topic ‘tribe_get_events query returns past recurring events’ is closed to new replies.

