Skip to content

Instantly share code, notes, and snippets.

@jondcampbell
Forked from joshfeck/example-query.php
Last active August 29, 2015 14:05
Show Gist options
  • Save jondcampbell/fce22cb0b701329a4b7c to your computer and use it in GitHub Desktop.
Save jondcampbell/fce22cb0b701329a4b7c to your computer and use it in GitHub Desktop.
Query event espresso 4 events and order by the events start date. Using this instead of a wp query of espresso_events post type.
<ul class="events">
<?php
$events_args = array(
'title' => NULL,
'limit' => 100,
'css_class' => NULL,
'show_expired' => FALSE,
'month' => NULL,
'category_slug' => NULL,
'order_by' => 'start_date',
'sort' => 'ASC'
);
// run the query
$events = new EE_Event_List_Query( $events_args );
if ($events->have_posts()) : while ($events->have_posts()) : $events->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
else:
?>
<li>No Upcoming Events</li>
<?php
endif;
// now reset the query and postdata
wp_reset_query();
wp_reset_postdata();
?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment