Skip to content

Instantly share code, notes, and snippets.

@aliciaduffy
Last active August 29, 2015 13:56
Show Gist options
  • Save aliciaduffy/8791099 to your computer and use it in GitHub Desktop.
Save aliciaduffy/8791099 to your computer and use it in GitHub Desktop.
Default Sort WordPress Post Types Admin by Date
<?php
function duffy_custom_post_types_admin_order($wp_query) {
if ( is_admin && ( get_query_var('orderby') == 'menu_order title' ) ) {
// 'orderby' value can be any column name
$wp_query->set('orderby', 'date');
// 'order' value can be ASC or DESC
$wp_query->set('order', 'DESC');
}
}
add_filter('pre_get_posts', 'duffy_custom_post_types_admin_order');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment