Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created May 18, 2012 03:11
Show Gist options
  • Save jo-snips/2722925 to your computer and use it in GitHub Desktop.
Save jo-snips/2722925 to your computer and use it in GitHub Desktop.
The Events Calendar: Custom Query Randomized
<ul>
<?php
global $post;
$current_date = date('n/j/Y',strtotime('1 day'));
$end_date = date('n/j/Y', strtotime('7 days'));
echo 'Current 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'=>6,
'orderby'=>'rand'
)
);
foreach($all_events as $post) {
setup_postdata($post);
?>
<li>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<span><?php echo tribe_get_option('Name', 'testing'); ?></span>
<span class="event-date"><a href="<?php the_permalink(); ?>"><?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="<?php the_permalink(); ?>"><?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 } ?>
</li>
<?php } //endforeach ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment