Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Order galleries in admin by date
// Add this to your theme's functions.php file
// Or use this plugin
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