Home › Forums › Calendar Products › Events Calendar PRO › Recurring events in a custom query?
- This topic has 2 replies, 2 voices, and was last updated 10 years, 3 months ago by
Brook.
-
AuthorPosts
-
January 4, 2016 at 2:18 pm #1050063
journal multimedia
ParticipantI’ve been searching through the forms and can’t seem to find a clear answer to this.
On my site, I’m doing a custom query and then dumping the contents using:
$monthlyevents = tribe_get_events( array(
'eventDisplay' => 'custom',
'start_date' => '2016-02-01 00:00',
'end_date' => '2016-02-29 23:59'
));var_dump($monthlyevents);
This returns an array of events from February of this year. In the var_dump, I only see one instance of a recurring event with a start date (ex: 2/2/16) and end date (ex: 2/26/16) . This would be okay, but in the array I don’t see any way to figure out the recurrence pattern either. Is there something I’m overlooking?
Here is an example of the event data for one recurring event in the array:
[3]=>
object(WP_Post)#446 (26) {
["ID"]=>
int(18143)
["post_author"]=>
string(2) "45"
["post_date"]=>
string(19) "2015-12-07 15:59:30"
["post_date_gmt"]=>
string(19) "2015-12-07 20:59:30"
["post_content"]=>
string(569) "Babies at the Barre™ is a “Mommy and me” style exercise class, designed to be done while baby is in a carrier, for new parents and their babies. Babies at the Barre™ is a mix of basic ballet and pilates exercises completed at the ballet barre and on the floor. Exercises focus on rebuilding strength in the pelvic floor as well as increasing flexibility and toning arms, core, calves, and buns, all while bonding with baby. No prior dance or pilates experience is required to participate in class.
Advanced registration is required-use registration code #18790"
["post_title"]=>
string(22) "Babies at the Barre™"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(6) "closed"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(21) "babies-at-the-barre-3"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2015-12-07 15:59:30"
["post_modified_gmt"]=>
string(19) "2015-12-07 20:59:30"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(33) "http://www.centralpennparent.com/"
["menu_order"]=>
int(0)
["post_type"]=>
string(12) "tribe_events"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
["EventStartDate"]=>
string(19) "2016-01-11 16:30:00"
["EventEndDate"]=>
string(19) "2016-02-15 17:30:00"
}
January 5, 2016 at 11:19 am #1050669journal multimedia
ParticipantAfter digging around a bit, I realized tribe_get_events doesn’t return all of the event information. For anyone else who stumbles across this, the functions archive is here https://theeventscalendar.com/functions/
For the recurrence pattern, you can just call tribe_get_recurrence_start_dates inside your loop:
$monthlyevents = tribe_get_events( array( 'eventDisplay' => 'custom', 'start_date' => '2016-02-01 00:00', 'end_date' => '2016-02-29 23:59' )); var_dump($monthlyevents); foreach($monthlyevents as $monthlyevent){ var_dump (tribe_get_recurrence_start_dates($monthlyevent->ID)); }January 5, 2016 at 10:54 pm #1050904Brook
ParticipantNice find Journal! I am happy you got a solution going already. Thanks for sharing it with everyone else.
It is true, tribe_get_events only gets the typical post information. Specialized queries like recurrence info can be pretty taxing on a database when run unnecessarily, so it does not return those as part of the post loop 9/10 times it’s not necessary.
Let us know if you ever need anything else. Thanks for marking this resolved!
Cheers!
– Brook
-
AuthorPosts
- The topic ‘Recurring events in a custom query?’ is closed to new replies.
