Home › Forums › Calendar Products › Events Calendar PRO › Need help with get_posts and recurring events
- This topic has 3 replies, 2 voices, and was last updated 6 years ago by Joakim.
-
AuthorPosts
-
April 24, 2018 at 6:27 am #1514627JoakimParticipant
I’m using get_posts to retrieve events on a page like this:
$posts = get_posts(array(
'numberposts' => 8,
'post_type' => array('tribe_events'),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'forsidesak',
'value' => 1,
'compare' => '==',
),
array(
'key' => '_EventStartDate',
'value' => $today,
'compare' => '>=',
),
),
'orderby' => '_EventStartDate',
'order' => 'ASC',
));For recurring events I need to display only the first event. How can I do that here? Is it possible to check if an event is part of a series of recurring events, get the first date of the series, get the start date of the event we’re fetching, and if the two start dates are different, don’t fetch it?
April 25, 2018 at 12:34 pm #1516266VictorKeymasterHi Joakim!
Thanks for getting in touch with us!
First, please let me note that we are fairly limited in how much support we can give for custom development questions like that.
That said, we always like helping out and at least point users into the right direction as much possible.
For custom event queries I’d recommend you take a look at the following article about the tribe_get_events() helper function > https://theeventscalendar.com/knowledgebase/using-tribe_get_events/
In recurring events, every recurring instance is a child event (child post) of the main event. You can also use the tribe_is_recurring_event() function to see if an event is recurring.
You will find that and other helpful functions in /wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php
I hope that helps you get started. Let me know if any follow up questions.
Best,
VictorApril 26, 2018 at 6:58 am #1516785JoakimParticipantThanks! Your answer led me to this very simple solution; by adding
'post_parent' => 0
to the parametres.- This reply was modified 6 years ago by Joakim.
April 26, 2018 at 1:48 pm #1517331VictorKeymasterRight on Joakim! Glad to know you could accomplish that 🙂
Thanks for following up to let us know.
I’ll go ahead and close this thread now, but feel free to open a new topic if anything comes up and we’ll be happy to help.
Cheers,
Victor -
AuthorPosts
- The topic ‘Need help with get_posts and recurring events’ is closed to new replies.