WordPress Order by Date Post_type Page in Admin Page List

WordPress Order by Date Post_type Page in Admin Page List

If you are wondering to find out the solution of post_type page order list in WP admin page list, you landed on the right place. By Default WP list our page order with alphanumerically orders.

WP Order by Date or Latest Post_type Page in Admin

To show your page list order by date in your wordpress admin dashboard just paste Code in your functions.php file.

To do this we need to hook up the build in function pre_get_posts. Inside that function we will also need to check whether it is a Admin with is_admin function. The Complete code for Order by latest Page in Admin is given bellow.

function ntafzal_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 == 'page') {

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

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

Related Posts

Add Your Comment


Comments

No comments found.