How to change sort order of shortcode [eo_events] from ASC to DESC
-
Dear Stephen,
I use the following shortcode in a WordPress page to integrate a list of events of a certain category:
[eo_events event_category="XYZ"]
The list should show newest events on top and older events at the bottom (DESC). The default behaviour is to sort the results ASC.
I was able to adapt the order of the results in the event archive by adding the following filter to my theme’s function.php, but it does not affect the sort order of the results from the eo_events shortcode.
add_filter('posts_orderby','my_eventorganiser_sort_events',20,2); function my_eventorganiser_sort_events( $orderby, $query ){ global $wpdb; if( empty($query->query_vars['orderby']) ){ if( eventorganiser_is_event_query( $query, true ) ){ $orderby = " {$wpdb->eo_events}.StartDate DESC, {$wpdb->eo_events}.StartTime DESC"; } } return $orderby; }
What would be the correct filter to add for the shortcode?
Thanks in advance,
Matthieu
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to change sort order of shortcode [eo_events] from ASC to DESC’ is closed to new replies.