The Events Calendar
Querying Events for page templates (4 posts)

  1. chris
    Posted 4 years ago #

    I have two pages that I would like to query events for. One is for Upcoming events, and one is for Past events. Do you guys have any guidance as to what I need to query to output these? Thanks.


  2. Betsy
    Posted 4 years ago #

    It's disappointing that you didn't get a reply for this, as this is the same question I have.

  3. Preeminent
    Posted 4 years ago #

    Yeah, I just posted on another post about this. Hoping for an answer soon! Bump

  4. tanmccuin
    Posted 4 years ago #

    Hi guys - below is some code i and a co-developer put together to create a little upcoming events widget on the homepage of a client site.

    The long short of it is that i query the events category (category 5, in this case.) but in order to not get everything (including passed events) and to keep it to only events that are upcoming or current, i had to dig into the post meta keys, and do a meta compare against the date. You can disregard the the thumbnail code, that's just there because i'm pulling event thumbnails as well. Hope this helps a bit.


          <div id="upcoming_events" class="homepage_element">
            <h4>Upcoming Events</h4>
    $current_date = date("Y-m-d");
    $cat5 = new WP_Query(array('cat' => 5,
    'showposts' => 6,
    'meta_key' => '_EventEndDate',
    'meta_value' => $current_date,
    'meta_compare' => '>='));     
    if($cat5->have_posts()) : while($cat5->have_posts()) : $cat5->the_post(); ?>
    <li style="clear:both;">
    <?php echo the_post_thumbnail(array(70,50), array('class' => 'alignleft')); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                <?php the_title(); ?>
    <?php endwhile; endif; ?>
              <li><a class="more" href="/events-ticket/events/">Full Schedule</a></li>
          <!-- END UPCOMING EVENTS-->

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • The Events Calendar
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic