Order posts in Admin by date published?
-
I recently did a batch update to posts in order to change the Author. However, now all the posts in my Admin area are listed by Date Modified — which is the same for all posts (because I batch modified them).
How can I get this back to displaying posts by newest first according to Published Date?
I’ve searched around and can’t find anything that describes this problem.
I tried adding this to my functions.php, but it didn’t work …
/* Sort posts in Admin area. */ function custom_post_order($query){ $post_types = get_post_types('', 'names'); /* The current post type. */ $post_type = $query->get('post_type'); /* Check post types. */ if(in_array($post_type, $post_types)){ /* Post Column: e.g. title */ if($query->get('orderby') == ''){ $query->set('orderby', 'post_date'); } /* Post Order: ASC / DESC */ if($query->get('order') == ''){ $query->set('order', 'DESC'); } } } if(is_admin()){ add_action('pre_get_posts', 'custom_post_order'); }
It’s a modified piece of code from this post.
Thanks!
- The topic ‘Order posts in Admin by date published?’ is closed to new replies.