Hi @sir-robin,
Thanks for reaching out! By default, the Elementor widget sorts past events by start date, but we can modify the query to use the event’s end date for descending order. Update the code in your functions.php
file (path for this file: events-widgets-for-elementor-and-the-events-calendar>>includes>>functions.php) Comment the code from line 39 to line 52 and add with the following modification:
For more, you can refer to this screenshot.
$orderby = 'event_date';
if ($meta_date_compare == '<') {
$orderby = '_EventEndDate';
}
$ect_args = apply_filters(
'ectbe_args_filter',
array(
'post_status' => 'publish',
'posts_per_page' => $settings['ectbe_max_events'],
'meta_key' => $attribute['key'],
'orderby' => $orderby,
'order' => $settings['ectbe_order'],
'meta_query' => $attribute['meta_date'],
),
$attribute,
$meta_date_date,
$meta_date_compare
);
This will make sure past events are sorted by their end date in descending order. Let me know if you face any issues with this.