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;
}
That’s the only thing there is to do: array manipulation.
The filter
manage_edit-CPT_columns
is fired inclass-wp-list-table.php
:Which in turn dispatches the function
get_columns()
in the sub-classclass-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.