-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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