Displaying Today's Events (Including Recurring Ones)

Home Forums Calendar Products Events Calendar PRO Displaying Today's Events (Including Recurring Ones)

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #78639
    Marcus
    Participant

    Hello, 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.

    #78640
    Marcus
    Participant

    Hmm, that didn’t post a lot of the code, but you can see the important parts, where the query is formed.

    #78776
    Barry
    Member

    Yeah 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?

    #79986
    Tim
    Participant

    I’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?

    #80028
    Tim
    Participant

    This 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’); ?>

    #80125
    Marcus
    Participant

    Thanks 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.

    #80127
    Tim
    Participant

    Thanks 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.

    #80151
    Barry
    Member

    Would 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!

    #80583
    Tim
    Participant

    Thanks 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!

    #80589
    Marcus
    Participant

    A 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.

    #80799
    Barry
    Member

    Thanks 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 🙂

    #91102
    Barry
    Member

    It’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!

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Displaying Today's Events (Including Recurring Ones)’ is closed to new replies.