Skip to content

Instantly share code, notes, and snippets.

@BeardedGinger
Last active December 23, 2015 06:39
Show Gist options
  • Save BeardedGinger/6595746 to your computer and use it in GitHub Desktop.
Save BeardedGinger/6595746 to your computer and use it in GitHub Desktop.
Modern Tribe's Events Calendar Upcoming Events Shortcode
add_shortcode( 'upcoming_events', 'upcoming_events_shortcode' );
/*
* Upcoming Events Shortcode
*
*/
function upcoming_events_shortcode() {
$args = array(
'post_type' => 'tribe_events',
'posts_per_page' => 3
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$events .= '<li>'.get_the_title().''.tribe_get_start_date( $post->ID, false, ' M j, Y' ) .' <a href="'.get_permalink().'">Read More <span class="icon-play"></span></a></li>';
}
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
return $events;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment