WP Admin Custom Post Type sort order

This is a function to do it easily:

This might be better: http://scribu.net/wordpress/custom-sortable-columns.html

/*-----------------------------------------------------------------------------------*/
/* CUSTOM ORDER A CUSTOM POST TYPE IN THE WP ADMIN EDIT.PHP SCREEN */
/*---------------------------------------------------------------------*/
function posts_for_current_author($query) {

 if($query->is_admin) {

 if ($query->get('post_type') == 'articles')
 {
 $query->set('orderby', 'date');
 $query->set('order', 'DESC');
 }
 }
 return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');

Revisions

Tags: , , ,

No comments yet.

Leave a Reply