• Resolved controlz

    (@controlz)


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

    https://www.ads-software.com/extend/plugins/the-events-calendar/

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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!

    Thread Starter controlz

    (@controlz)

    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–>

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Expired events not being removed from eventDisplay’ is closed to new replies.