tribe_get_events query returns past recurring events

Home Forums Calendar Products Events Calendar PRO tribe_get_events query returns past recurring events

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1056756
    Admin
    Participant

    I have a relatively simple query that returns 3 current day events. It works fine except for recurring events. I have a weekly recurring event and the first instance of that recurring events always appears at the top of the results list. The site in question is under development and password protected so I cannot send a link, but please see my code below. The screenshot was taken today, January 15th and shows the weekly recurring event that began on 1/12 along with two correct events that are scheduled for today. I hope you can suggest a fix. Thanks!

    Screenshot:

    View post on imgur.com

    $start_date = date("Y-m-d");
      $end_date = date("Y-m-d", strtotime("+1 day"));
      $events = tribe_get_events( array(
        'posts_per_page' => 3,
        'eventDisplay' => 'custom',
        'start_date' => $start_date,
        'end_date' => $end_date,
      ) );
    #1056810
    Brian
    Member

    Hi,

    Thanks for using our plugins. I can help out here.

    Try adding this to your query:

    'tribeHideRecurrence' => true,

    That should prevent recurring events from being included.

    Does that work?

    #1056828
    Admin
    Participant

    Thanks for your reply. I had tried that already without success. My updated query with your suggestion had no affect – the past recurring event is still being displayed.

    $events = tribe_get_events( array(
        'posts_per_page' => 3,
        'eventDisplay' => 'custom',
        'start_date' => $start_date,
        'end_date' => $end_date,
        'tribeHideRecurrence' => true,
      ) );
    #1057872
    Brian
    Member

    Hi,

    What is the settings for the recurring event that is show? Does if have a instance on the 15th when you took that image?

    Is it still showing that one today?

    I tried to reproduce on my test site with a recurring event before today and it worked correctly for me and did not show.

    I can try to help out some more, but I am limited in troubleshooting customizations.

    Let me know though about your recurring event and I will test it out again.

    Thanks

    #1057915
    Admin
    Participant

    Hi Brian,
    Thanks again for your help with this. I have attached a new screenshot showing the settings for the recurring event. The event started on January 12th, recurring weekly. So no, it did not have an instance on the 15th.

    And yes, it is still showing the first instance (1/12) today.

    Hopefully the screenshot of the event settings may help.

    View post on imgur.com

    #1058139
    Brian
    Member

    Ok, I tried again and it did not pick up my recurring event so not sure why it is for you.

    Does this happen on a specific page? Can you try another?

    I can try to help out some more, but I am limited in troubleshooting customizations.

    Let me know though.

    #1058180
    Admin
    Participant

    Hi Brian,
    Well, I’m at a loss too. I’ve really got to get this working because it was really the only reason we purchased the Pro version of the events calendar – for the recurring events.

    So I created a stripped down page template for testing. You will need to enter a username and password to see the front end pages. First go to the home page
    http://frostscience.wpengine.com/
    u: frostscience
    p: 08336c16

    Then go to this link: http://frostscience.wpengine.com/recurring-event-test/

    You will see the past recurring event as the first result “Jan 12, Social Event – Recurring”.
    In my query I used ‘tribeHideRecurrence’ => true, which successfully turns off all other instances of the recurring event except for the first one. I will paste the full code from this page below:

    <?php
    /**
     * Template Name: Recurring Event Test
     *
     * @package frost
     */
    
    get_header(); ?>
    
    <div class="container-fluid">
    <div class="row">
    <div class="col-sm-12">
    
    <?php
    
    $start_date = date("Y-m-d", strtotime("+1 day"));
    $end_date = date("Y-m-d", strtotime("+365 day"));
    
      $events = tribe_get_events( array(
        'posts_per_page' => 10,
        'eventDisplay' => 'custom',
        'start_date' => $start_date,
        'end_date' => $end_date,
        'tribeHideRecurrence' => true,
      ) );
    
      foreach ( $events as $post ) : setup_postdata( $post );
    ?>
    
    <div>
    <?php echo tribe_get_start_date( $post->ID, false, 'M j, ' ); ?> <?php echo $post->post_title; ?>
    </div>
    
    <?php
    endforeach;
    wp_reset_postdata();
    ?>
    
    </div>
    </div>
    </div>
    
    <?php get_footer(); ?>
    #1058195
    Brian
    Member

    Hi,

    Thanks for that.

    I think I maybe have found the issue.

    This event:

    Social Event – Recurring

    Has a start date of January 12 and the end date February 12

    So set that way it is considered one long event for every day in between those dates, so it will always show first as the query considers it on going.

    That event should instead be setup with the start and end date as the same date and then it is repeated daily until the 12th.

    Like this:

    Tribe recurring daily

    Thanks

    #1058414
    Admin
    Participant

    That was it! The query is now working correctly. Thanks for your help!

    #1058622
    Brian
    Member

    Great, glad it helps, I am going to go ahead and close this ticket, but if you need help on this or something else please post a new ticket.

    Thanks!

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘tribe_get_events query returns past recurring events’ is closed to new replies.