Skip to content

Instantly share code, notes, and snippets.

@sunshinephotocart
Created November 13, 2019 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunshinephotocart/d6e527f122bdea9ccae5f00fcf5f1596 to your computer and use it in GitHub Desktop.
Save sunshinephotocart/d6e527f122bdea9ccae5f00fcf5f1596 to your computer and use it in GitHub Desktop.
Order galleries in admin by date
// 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