Home › Forums › Calendar Products › Events Calendar PRO › Display only today's events using WP_Query
- This topic has 4 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
January 22, 2012 at 9:01 pm #13812
Steve
MemberHi. I’m trying to display events happening today only, using the following query:
$today_start = date(‘Y-m-d H:i:s’,mktime(0, 0, 0, date(“m”) , date(“d”), date(“Y”)));
$today_end = date(‘Y-m-d H:i:s’,mktime(23, 59, 59, date(“m”) , date(“d”), date(“Y”)));
$todays_events = new WP_Query(array(
‘posts_per_page’ => -1,
‘order’ => ‘ASC’,
‘post_type’ => ‘tribe_events’,
‘meta_key’ => ‘_EventStartDate’,
‘orderby’ => ‘meta_value’,
‘meta_query’ => array(
array(
‘key’ => ‘_EventStartDate’,
‘value’ => array( $today_start, $today_end ),
‘type’ => ‘DATETIME’,
‘compare’ => ‘BETWEEN’
)
),
));
if($todays_events->have_posts()){
while ($todays_events->have_posts()) : $todays_events->the_post();
//do stuff
======The problem is, for recurring events, it’s displaying ALL the recurrences. See an example here:
http://dpractice.postmodernsublime.com/
Under “Today’s Events” at the bottom of the page, there are 150 events.How can I get it to display only events from a certain day (ie today)? Should I be using tribe_get_events instead of a Loop? And how would I do that?
Thanks,
SteveJanuary 23, 2012 at 10:44 am #13859Rob
MemberHey Steve. Thanks for reaching out. I can definitely get a dev to chime in here as needed; but first, have you checked out our documentation page at https://theeventscalendar.com/support/documentation ? It gives examples of how the template tags, etc should work to accomplish what you’re going for here. But let me know if not or if I’ve misinterpreted the request, and we can elaborate here as needed.
January 23, 2012 at 10:57 am #13868Steve
MemberHi Rob, thanks. I was looking in the wrong place for such documentation. tribe_get_events worked perfectly.
Thanks for the quick response, and for having documentation, and for generally being one of the only plugin companies that takes it seriously. $50 well spent.
January 23, 2012 at 11:26 am #13884Rob
MemberExcellent to hear that worked, and thanks for the words – we do what we can 🙂 If you need anything else moving forward let us know; we don’t hit the forums much moer the weekends but are checking it a few times a day M-F and will do what we can to get you responses in as timely a fashion as possible.
July 3, 2015 at 5:00 pm #975368Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Display only today's events using WP_Query’ is closed to new replies.
