Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active October 1, 2018 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/448a112d0ce05fb6e7d57a63a201e4e4 to your computer and use it in GitHub Desktop.
Save cliffordp/448a112d0ce05fb6e7d57a63a201e4e4 to your computer and use it in GitHub Desktop.
Events Calendar PRO: `tribe_events` shortcode: List View: Reverse sort ordering of results.
<?php
/**
* Events Calendar PRO: `tribe_events` shortcode: List View: Reverse sort ordering of results.
*
* SHORTCOMING: Only works for initial load, not also for previous/next events navigation.
*
* @link https://gist.github.com/cliffordp/448a112d0ce05fb6e7d57a63a201e4e4 This snippet.
* @link https://central.tri.be/issues/115433 This snippet isn't sufficient so we need this ticket :(
*
* @return string
*/
function cliff_modify_tribe_events_shortcode_list_query( $query ) {
remove_action( 'pre_get_posts', 'cliff_modify_tribe_events_shortcode_list_query' );
if (
! empty( $query->query['eventDisplay'] )
&& 'list' === $query->query['eventDisplay']
) {
$query->query['order'] = 'DESC';
}
}
add_filter(
'tribe_events_pro_tribe_events_shortcode_prepare_list', function () {
add_action( 'pre_get_posts', 'cliff_modify_tribe_events_shortcode_list_query' );
}, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment