How to order posts of a custom post type by date DESC in dashboard Admin?

Alright, You can just hook into the filter pre_get_posts and check is_admin.
Put this in your theme or plugin:

function wpse_81939_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 == 'Videos') {

      $wp_query->set('orderby', 'date');

      $wp_query->set('order', 'DESC');
    }
  }
}
add_filter('pre_get_posts', 'wpse_81939_post_types_admin_order');

I also would shange the post_type “Videos” to lowercase like “video”.

Leave a Comment