WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
[resolved] Expired events not being removed from eventDisplay (4 posts)

  1. controlz
    Member
    Posted 1 year ago #

    I can't figure out why the events I have listed in a side menu continue to show past/expired events. I was hoping that when an event passed the PHP would get the next event and not continue to display events that have already ended.

    Here is the PHP I am using to call events:
    <?php
    global $post;
    $all_events = tribe_get_events(array(
    'eventDisplay'=>'all',
    'posts_per_page'=>3
    ));

    foreach($all_events as $post) {
    setup_postdata($post);
    ?>

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Hey controlz. What you're describing as your hope *should* be how it functions; I'm wondering if the query has an issue with it. (Im assuming you wrote that yourself, but let me know if not).

    Any chance you've got a link to the site, so we can check this out? I'll get a dev to take a look as needed from there. Thanks in advance!

  3. controlz
    Member
    Posted 1 year ago #

    I found the answer after some digging. I was using the wrong call. Here's what I ended up using which seems to be working as it should by only showing upcoming events.

    <section class="events">
    <h3>Upcoming Events</h3>

      <?php
      global $post;
      $current_date = date('j M Y');
      $end_date = date('j M Y', strtotime('30 days'));

      $get_posts = tribe_get_events(array('start_date'=>$current_date,'end_date'=>$end_date,'posts_per_page'=>3) );

      foreach($get_posts as $post) {
      setup_postdata($post);
      ?>

    • "><?php the_title(); ?>
    • <?php } //endforeach ?>
      <?php wp_reset_query(); ?>

    </section><!--events-->

  4. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Ah, thanks for confirming as much - glad to hear you got this sorted. Thanks, too, for sharing the results of your efforts...other users in the same boat who visit the forums later will definitely appreciate it.

    Sounds like you're all set here, but please let us know if you need anything else in the future. Thanks for using The Events Calendar.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.