Skip to content

Instantly share code, notes, and snippets.

@GeoffEW
Created October 18, 2016 21:58
Show Gist options
  • Save GeoffEW/f9de188d60f3a6f9e93cb050db7f7c0a to your computer and use it in GitHub Desktop.
Save GeoffEW/f9de188d60f3a6f9e93cb050db7f7c0a to your computer and use it in GitHub Desktop.
Adds past event possibilities to the tribe_events shortcode
<?php function tribe_past_events_shortcode( $atts ) {
if ( ! class_exists( 'Tribe__Events__Pro__Shortcodes__Tribe_Events' ) ) return '';
add_action( 'parse_query', 'tribe_past_events_shortcode_modify_query' );
$shortcode = new Tribe__Events__Pro__Shortcodes__Tribe_Events( $atts );
return $shortcode->output();
}
function tribe_past_events_shortcode_modify_query( $query ) {
$query->set( 'tribe_is_past', true );
remove_action( 'parse_query', 'tribe_past_events_shortcode_modify_query' );
}
add_shortcode( 'tribe_past_events', 'tribe_past_events_shortcode' );
@GeoffEW
Copy link
Author

GeoffEW commented Oct 18, 2016

folks could do [tribe_past_events view="list"]
obviously, we'd be trusting them not to perform madness like [tribe_past_events view="month"]
probably has shortcomings but may also be a reasonable start point (in advance of full-on support being rolled into [tribe_events] itself)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment