Change the order of columns for a custom post type on the admin list page

I have created a custom post type (screen shot below), and would like to change the order of columns. Is it possible to move the “tags” column before the “date” column?

Screen shot:

Screen shot

2 s
2

Yes this is possible. I have changed this for the default post type, but this is also possible for a custom one.

First check the codex:

http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column

function your_columns_head($defaults) {  

    $new = array();
    $tags = $defaults['tags'];  // save the tags column
    unset($defaults['tags']);   // remove it from the columns list

    foreach($defaults as $key=>$value) {
        if($key=='date') {  // when we find the date column
           $new['tags'] = $tags;  // put the tags column before it
        }    
        $new[$key]=$value;
    }  

    return $new;  
} 
add_filter('manage_posts_columns', 'your_columns_head');  

You can change the $defaults array as you like this way.

Leave a Comment