Ordering events by event start date / meta key

Ordering Events By Event Start Date / meta key

If you want to make events order by meta key or event start date you just need to add following code inside you theme’s function.php file. You can change you meta key instead of _event_start_date if you want to change order by any other meta key.


/** You need to put code in theme functions.php **/
function theme_name_custom_orderby( $query_args ) {
    $query_args[ 'orderby' ] = 'meta_value'; //orderby will be according to data stored inside the particular meta key
    $query_args[ 'order' ] = 'DESC';
    return $query_args;

add_filter( 'event_manager_get_listings_args', 'theme_name_custom_orderby', 99 );

function theme_name_custom_orderby_query_args( $query_args ) {
    $query_args[ 'meta_key' ] = '_event_start_date'; //here you can change your meta key
    return $query_args;

add_filter( 'get_event_listings_query_args', 'theme_name_custom_orderby_query_args', 99 );