WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom post type and trying to set custom columns, the date column is there by default, and it appears right after the title. Do I have to unset the date first and then re-apply it, or is there a more elegant way of achieving this:

function custom_columns($columns) {
    unset( $columns['date'] );

    $columns = array_merge($columns, array(
        'title'     => 'Alert Title',
        'region'    => 'Region',
        'date'      => 'Date',

    return $columns;
share|improve this question
I'd say there's nothing wrong with this approach... What problem do you have with it, sortable columns? – brasofilo Feb 6 '13 at 23:49
I don't have a problem with it, I was just wondering if there was a better way of doing it. Seems 'hacky' to be unsetting it just to set it in a different spot – keeg Feb 7 '13 at 3:23
It's just array manipulation, I've done hackier things ;) – brasofilo Feb 7 '13 at 3:27
lol, k. I thought maybe there was a menu_position type of thing... – keeg Feb 7 '13 at 3:30
up vote 1 down vote accepted

That's the only thing there is to do: array manipulation.

The filter manage_edit-CPT_columns is fired in class-wp-list-table.php:

add_filter( "manage_{$this->screen->id}_columns", array( &$this, 'get_columns' ), 0 );

Which in turn dispatches the function get_columns() in the sub-class class-wp-posts-list-table.php.

And, inside it, one filter for taxonomies, and others for post/page/cpt columns.
And all of them dealing with array elements.
Maybe a one line solution exists with some PHP function, but two lines is valid code too.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.