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:

Read More

Screen shot

Related posts

2 comments

  1. 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.

  2. Yes You can change the order of your list shown in Admin Panel. First you have to unset the default array after that make array of your choice let me show with example
    The following image show custom post type default field.
    enter image description here

    Now let me show you how you can remove some extra field from this list. Suppose i want to remove the title and tags field from the list and add my custom post type field and also rearrange the order of list fields

         function add_ourteam_columns ( $columns ) {
        unset($columns['title']);
        unset($columns['tags']);
        unset($columns['date']);
       return array_merge ( $columns, array ( 
         'name' => __ ('name'),
         'designation' => __ ( 'Designation' ),
         'image'   => __ ( 'Image' ),
         'date' => __('Date')
       ) );
    
     }
    
    add_filter ( 'manage_our-team_posts_columns', 'add_ourteam_columns' );
    

    enter image description here

    If you want to remove the field just use unset(field_name), if you want to change the order of the list first unset that field then make a new array and add that field after or before other field. I hope this example would help you

Comments are closed.