Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Events5

Show past 5 events

// Add Shortcode
function hcc_past_events_shortcode() {

	// Code
ob_start();?>

	<?php
	$args = array( 'post_type' => 'event', 'event_status'=>'past-event', 'posts_per_page' =>5);
		$loop = new WP_Query( $args );
		while ( $loop->have_posts() ) : $loop->the_post();
		
			echo '<div style="width:90%; height:auto; margin-bottom:-20px;"><a href="', get_permalink(), '">';
							if (has_post_thumbnail()) {
								the_post_thumbnail();
							}
							else {
								echo 
									'';
							}
			echo '</a></div>';
			
			echo '<a href="', get_permalink(), '">';
			the_title();
			echo '</a><br>';
		endwhile;
	?>

<?php
return ob_get_clean();	
			
}
add_shortcode( 'hcc_past_events', 'hcc_past_events_shortcode' );