Home › Forums › Calendar Products › Events Calendar PRO › Displaying Today's Events (Including Recurring Ones)
- This topic has 11 replies, 3 voices, and was last updated 12 years, 3 months ago by
Barry.
-
AuthorPosts
-
November 26, 2013 at 6:46 am #78639
Marcus
ParticipantHello, I’m attempting to have a “Today’s Events” sidebar powered by our Tribe Events database. While I’m able to capture single, non-recurring events for a given day, recurring events do not appear for some reason. I’ve scoured the forums and web and came up with two separate approaches, though each have this same problem.
Approach #1:
query(‘posts_per_page=’.$show_posts.
‘&post_type=’.$post_type.
‘&order=ASC’.
‘&orderby=date’.
‘&start_date=’.$todays_date
);$count_posts = wp_count_posts($post_type);
if ($wp_query->have_posts()){ while($wp_query->have_posts()){ $wp_query->the_post();
?>
<a href="”>Location:
No events listed for today, .
Approach #2:
$current_date, ‘end_date’ => $current_date, ‘eventDisplay’ => ‘upcoming’, ‘posts_per_page’ => $show_posts );
$wp_query = TribeEventsQuery::getEvents( $args, true );$count_posts = wp_count_posts($post_type);
if ($wp_query->have_posts()){ while($wp_query->have_posts()){ $wp_query->the_post();
?>
<a href="”>Location:
No events listed for today, .
Any additional ideas or feedback would be much appreciated.
November 26, 2013 at 6:47 am #78640Marcus
ParticipantHmm, that didn’t post a lot of the code, but you can see the important parts, where the query is formed.
November 26, 2013 at 5:26 pm #78776Barry
MemberYeah the forum doesn’t do a great job with posted code – it is usually best to use a service like Pastebin or Gist and drop a link in here instead.
Have you tried using tribe_get_events() (which is essentially an event-oriented wrapper around WP Query) instead?
December 3, 2013 at 3:19 pm #79986Tim
ParticipantI’m also looking for an answer to this. the tribe_get_events() documentation is outdated (only works for 2.1 and below) so I’m hoping this is just a simple update to get working.
Can someone please help?
December 3, 2013 at 4:31 pm #80028Tim
ParticipantThis solution worked for me to show only todays events:
4,
‘eventDisplay’ => ‘upcoming’
)
);
foreach($upcoming_events as $post) {
if (tribe_get_start_date( null, false, ‘Y-m-d’ ) >= $now) { break; }
?>
<a href="”> | ID, false, ‘g:iA’); ?>December 4, 2013 at 7:48 am #80125Marcus
ParticipantThanks for sharing, Tim. I’d also noticed that much of the helpful documentation I found online applied only to version 2.1. While your code doesn’t quite come through on this forum, I believe I did something similar where I looped through a number of entries and used tribe_get_start_date to compare against current time. It’s putting the system through some extra paces, but it’s all I could figure out as well.
December 4, 2013 at 7:57 am #80127Tim
ParticipantThanks for checking back Marcus. Here’s the code I used:
https://gist.github.com/creativeslice/7790023
If anyone has a better way to show just todays events I’d love to see it. This feels a bit brittle.December 4, 2013 at 10:07 am #80151Barry
MemberWould something like this work for you?
I’m also looking for an answer to this. the tribe_get_events() documentation is outdated (only works for 2.1 and below)
Can you point to the documentation you were reading? We’d love to remove it / make it clearer that it is obsolete. Thanks!
December 6, 2013 at 12:49 pm #80583Tim
ParticipantThanks Barry, that seemed to work however we are now having issues where recurring events show up multiple times.
Is there a way to have a recurring event only show up once for the day they are happening?
Thanks!
December 6, 2013 at 1:02 pm #80589Marcus
ParticipantA sidenote, Barry: When searching for the solution for this and other questions, here’s the 2.X documentation I kept running into:
https://theeventscalendar.com/support/documentation/the-events-calendar-template-tags-general-functions/
It’d be great to have a collection of these kind of general functions for 3.X posted somewhere.December 9, 2013 at 7:39 am #80799Barry
MemberThanks Barry, that seemed to work however we are now having issues where recurring events show up multiple times.
Not quite sure why you are hitting this, Tim, or what the exact context is. If for instance I set up the snippet I suggested in a custom page template and have two events scheduled for today (one that is a single event and the other a recurring event that happens to have one instance taking place today) then I see two events as expected, I don’t see additional instances of the recurring event.
When searching for the solution for this and other questions, here’s the 2.X documentation I kept running into:
https://theeventscalendar.com/support/documentation/the-events-calendar-template-tags-general-functions/
It’d be great to have a collection of these kind of general functions for 3.X posted somewhere.We did try to make it as clear as possible that items like that tutorial don’t pertain to the current version – so please accept our apologies if that wasn’t the case.
We’re definitely conscious that we need to build up our 3.x-related documentation and that’s something we’ll keep chipping away at over time 🙂
January 13, 2014 at 6:43 am #91102Barry
MemberIt’s been a while so I’ll go ahead and close this thread. Of course if you need further help for this or any other issue please do feel free to create a new thread or threads as needed. Thanks!
-
AuthorPosts
- The topic ‘Displaying Today's Events (Including Recurring Ones)’ is closed to new replies.
