Order galleries in admin by 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
// Add this to your theme's functions.php file | |
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/ | |
add_filter( 'pre_get_posts', 'sunshine_order_galleries_by_date_in_admin' ); | |
function sunshine_order_galleries_by_date_in_admin( $wp_query ) { | |
global $pagenow; | |
if ( is_admin() && $_GET['post_type'] == 'sunshine-gallery' && 'edit.php' == $pagenow && !isset( $_GET['orderby'] ) ) { | |
$wp_query->set( 'orderby', 'date' ); | |
$wp_query->set( 'order', 'DESC' ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment