Created
March 5, 2013 04:47
-
-
Save jo-snips/5088084 to your computer and use it in GitHub Desktop.
The Events Calendar - Order Events In Admin By Start Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*-----------------------------------------------------------------------------------*/ | |
/* Modify Event List Order in Admin | |
/*-----------------------------------------------------------------------------------*/ | |
function set_custom_post_types_admin_order($wp_query) { | |
if (is_admin()) { | |
// Get the post type from the query | |
$post_type = $wp_query->query['post_type']; | |
if ( $post_type == 'tribe_events') { | |
// 'orderby' value can be any column name | |
$wp_query->set('orderby', 'meta_value'); | |
$wp_query->set('meta_key', '_EventStartDate'); | |
// 'order' value can be ASC or DESC | |
$wp_query->set('order', 'DESC'); | |
} | |
} | |
} | |
add_filter('pre_get_posts', 'set_custom_post_types_admin_order'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment