Hello friend, this code worked for me. I couldn’t figure out how to do it using elementor visually. But you can just add this to your theme function. Something like that would work.
You want to use the pre-get post which runs before the query gets printed.
https://www.advancedcustomfields.com/resources/orde-posts-by-custom-fields/
function my_pre_get_posts( $query ) {
// do not modify queries in the admin
if( is_admin() ) {
return $query;
}
// only modify queries for 'event' post type
if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'events' ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'Anno');
$query->set('order', 'Asc');
}
// return
return $query;
}
add_action('pre_get_posts', 'my_pre_get_posts');
Good luck!
Giovani Camara,
https://giovanicamara.com