initial sort order for a sortable custom column in admin

Instead of adding your column label "view" as a string, pass it in as an array with 1 as the second value. Like this: array('view',1)

Full Code:

add_filter( 'manage_edit-post_sortable_columns', 'my_sortable_view_column' );
function my_sortable_view_column( $columns ) {
    $columns['post_views'] = array('view',1);
    return $columns;
}

I don’t have a WP Codex for this, but I found someone else posted a solution here:
http://www.weblogmechanic.com/2014/02/13/making-custom-column-wordpress-admin-sort-reverse-order/

Leave a Comment