Skip to main content
Robert Michalski

Sort columns in WordPress admin

Sometimes it's convenient to have certain columns first depending on how you work and what information is important to you.

The columns can be reordered quite easily by just reordering an array in the correct WordPress filter, see manage_{$post_type}_posts_columns.

WooCommerce specific

if (is_admin()) {
    add_filter('manage_page_posts_columns', 'YOUR_PREFIX_admin_reorder_page_columns');

    function YOUR_PREFIX_admin_reorder_page_columns($columns) {
        $n_columns = [];
        // create a list of columns in the desired order
        $order = [
            'title',
            'date',
            'author'
            // custom columns can also be added here
        ];
        // remove them from the existing array
        foreach($order as $key) {
            if (array_key_exists($key, $columns)) {
                $n_columns[$key] = $columns[$key];
                unset($columns[$key]);
            }
        }
        // merge the arrays
        return array_merge($n_columns, $columns);
    }
}