Support » Plugin: The Events Calendar » Querying Events for page templates

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

    Chris

Viewing 3 replies - 1 through 3 (of 3 total)
  • It’s disappointing that you didn’t get a reply for this, as this is the same question I have.

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

    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.

    -T

    <!--UPCOMING EVENTS-->
          <div id="upcoming_events" class="homepage_element">
            <h4>Upcoming Events</h4>
      <ul>
       <?php
    $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(); ?>
                </a>
    </li>
    <?php endwhile; endif; ?>
              <li><a class="more" href="/events-ticket/events/">Full Schedule</a></li>
            </ul>
          </div>
          <!-- END UPCOMING EVENTS-->
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Querying Events for page templates’ is closed to new replies.