Ordering Events By Event Start Date / meta key
In WP Event Manager do you want to change the order of your events? do you want them to arrange by event start date/ meta Key?
The following steps help you to arrange these events(Ordering Events By Event Start Date/meta key):
Ordering Events By Event Start Date / meta key
- Open your child theme.
- Add the following code in the function.php file.
<?php /** 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 ); ?>
- You can change your meta key instead of _event_start_date if you want to change the order by any other meta key.