Do You Want to Learn Marketing or Coding? Do You Want to Learn Marketing or Coding? The Event Calendar Custom Shortcodes

Share on facebook
Share on twitter
Share on linkedin

If you are using’s WordPress Event Calendar, sometimes you might want to display event information in a page using a shortcode. Unfortunately the plugin doesn’t have this out of the box, but luckily it is easy enough to add.

First go to your themes function.php file and back-it up.

Second paste in the following code:

add_shortcode('event_code', 'events_shortcode');
function events_shortcode() {

	$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
	$upcoming = new WP_Query();
	$upcoming->query( array(
		'post_type'=> 'tribe_events',
		// 'eventDisplay' => 'past',
		'posts_per_page' => 3,
		'paged' => $paged)
	$return_string = '';
	if ($upcoming->have_posts()) :
		while ($upcoming->have_posts()) :
			$return_string .= '<strong><a href="'.get_permalink().'">'.get_the_title().'</a></strong> <br/>';
			$return_string .= tribe_events_event_schedule_details();
			$return_string .= '<br/><br/>';
		if ( function_exists('wp_pagenavi') ) wp_pagenavi( array( 'query' => $upcoming ) ); // tell it which query we are paginating
	wp_reset_query(); // important to reset the query
	$return_string .= '<a href="'.tribe_get_events_link().'">View All Upcoming Events</a>';
	return $return_string;

Next go to the page you would like to add the shortcode. On this page add the following.


Save the page, and now you should see some event information. If you would like to view more or less events on the page edit value in the above code. For example, if you want to change from showing 3 events to 2, go to:

'posts_per_page' => 3,

And change the 3 to 2.

'posts_per_page' => 2,

That is it!

If you have any questions please feel free to contact me through the comments section below. Also be sure to checkout my Visalia Web Design services.

I Really Need

Reviewing nerdy stuff is expensive.

Consider clicking on this ad & buying that item you REALLY wanted from Amazon.

It helps a ton!

Leave Your Thoughts