Home › Forums › Calendar Products › Events Calendar PRO › Get events for specific day ONLY
- This topic has 4 replies, 3 voices, and was last updated 9 years, 9 months ago by
Cliff.
-
AuthorPosts
-
July 25, 2016 at 3:33 pm #1143862
Julia Kay
ParticipantHi,
I have been looking through the documentation to see if I can search for the events falling on a specific day.
I have found tribe_get_events() and this appeared to do what I need but I have run into the following cases:
I have three events: 1 full day event on 22nd July; 1 event that starts on 22nd July and finishes on 23rd July; 1 full day event on the 23rd July.
I am looking to display only the events that start on July 22nd.
I do:tribe_get_events( array( 'posts_per_page' => -1, 'start_date' => '2016-07-22' ) );This returns ALL events from July 22nd onwards.
If I adjust my query to:
tribe_get_events( array( 'posts_per_page' => -1, 'start_date' => '2016-07-22', 'end_date' => '2016-07-23' ) );This returns only the full day event for July 22nd.
Is there any adjustment that I can make to this query to return events starting/happening ONLY on the 22nd July no matter what their end date? I am looking at a situation where events can go for a day for up to an unknown length of time. At best, at the moment, I can guess the extreme and then manually filter for July 22nd only but would prefer a query that returns all correct results.
For some context:
I am trying to edit the Month view of the Calendar so that if a day is clicked then the events for that day appear to the side of Calendar with some brief information (as opposed to the name displaying in the day area and hovering to find this information). As I am outside of the month loop I am not able to take advantage of tribe_events_get_current_month_day() (as far as I can tell ). I have attached visuals of what I am trying to attempt.July 25, 2016 at 8:59 pm #1143985Cliff
MemberHi Julia. Thanks for your detailed question.
Have you referenced our Using tribe_get_events() KB article?
Based on that article, my first suggestion would be to try your start_date as 2016-07-22 00:00 (or possibly ending in 00:01) and your end_date as 2016-07-22 23:59
Other than that, I cannot provide much customization help. But please let me know if you have follow-up questions.
As a general reminder of best practices when developing your site:
Please make sure all your Modern Tribe plugins (and WordPress core) are at their latest versions:
And follow our Testing for Conflicts Guide (basically switch to TwentySixteen theme and deactivate all plugins and custom code other than Modern Tribe plugins) to make sure things work in the “default” / fresh / basic environment (also good to disable any caching).
You should also enable WP_DEBUG and keep an eye on your console at your site. (If needed, you may reference our KB article Using Google Chrome Developer Tools.)
Let us know what you find out.
Thanks.
July 25, 2016 at 9:07 pm #1143989Julia Kay
ParticipantThank you very much.
An adjustment to
tribe_get_events( array( 'posts_per_page' => -1, 'start_date' => '2016-07-22 00:00', 'end_date' => '2016-07-22 23:59' ) );Returns all events falling on that day, including my event ending on the 23rd which was previously being dropped off.
July 25, 2016 at 9:29 pm #1144001Cliff
MemberAwesome! Thanks for letting me know. 🙂
-
AuthorPosts
- The topic ‘Get events for specific day ONLY’ is closed to new replies.
