Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created September 9, 2012 23:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jo-snips/3687846 to your computer and use it in GitHub Desktop.
Save jo-snips/3687846 to your computer and use it in GitHub Desktop.
The Events Calendar: Custom Query for 1 Month Future Events
<?php
global $post;
$current_date = date('j M Y');
$end_date = date('j M Y', strtotime('1 month'));
echo 'Start Date:'. $current_date;
echo 'End Date:'. $end_date;
$all_events = tribe_get_events(
array(
'start_date' => $current_date,
'end_date'=> $end_date,
'posts_per_page' => 5
)
);
foreach($all_events as $post) {
setup_postdata($post);
?>
<h3 class="entry-title"><a href="<?= tribe_get_event_link($post) ?>"><?php the_title(); ?></a></h3>
<div style="margin-bottom: 1em">
<span class="event-date"><a href="<?= tribe_get_event_link($post) ?>"><?php echo tribe_get_start_date($post->ID, true, 'M j, Y'); ?></a></span>
<?php if ( has_post_thumbnail() ) { ?>
<div class="event-thumb">
<a href="<?= tribe_get_event_link($post) ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
</div>
<div class="event-excerpt">
<?php the_excerpt(); ?>
</div>
<?php } else { ?>
<div class="event-content">
<?php the_content(); ?>
</div>
<?php } ?>
</div>
<?php } ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment