Using WordPress ‘manage_{$screen->id}_columns’ PHP filter

The manage_{$screen->id}_columns WordPress PHP filter allows you to modify the column headers for a list table on a specific screen.

Usage

add_filter('manage_edit-post_columns', 'my_custom_columns');
function my_custom_columns($columns) {
    // your custom code here
    return $columns;
}

Parameters

  • $columns (string[]): The column header labels keyed by column ID.

More information

See WordPress Developer Resources: manage_{$screen->id}_columns

Examples

Add a custom column to the Posts list table

This code adds a custom column called ‘Views’ to the Posts list table.

add_filter('manage_edit-post_columns', 'add_views_column');
function add_views_column($columns) {
    $columns['views'] = 'Views';
    return $columns;
}

Remove a default column from the Pages list table

This code removes the ‘Comments’ column from the Pages list table.

add_filter('manage_edit-page_columns', 'remove_comments_column');
function remove_comments_column($columns) {
    unset($columns['comments']);
    return $columns;
}

Change the label of a column in the Media list table

This code changes the ‘Uploaded to’ column label to ‘Attached to’ in the Media list table.

add_filter('manage_upload_columns', 'change_uploaded_to_label');
function change_uploaded_to_label($columns) {
    $columns['parent'] = 'Attached to';
    return $columns;
}

Reorder columns in the Users list table

This code reorders the columns in the Users list table, placing the ‘Posts’ column before the ‘Role’ column.

add_filter('manage_users_columns', 'reorder_user_columns');
function reorder_user_columns($columns) {
    $posts = $columns['posts'];
    unset($columns['posts']);
    $new_columns = [];

    foreach ($columns as $key => $value) {
        $new_columns[$key] = $value;
        if ($key == 'role') {
            $new_columns['posts'] = $posts;
        }
    }

    return $new_columns;
}

Add a custom column to a custom post type list table

This code adds a ‘Price’ column to the list table of a custom post type called ‘products’.

add_filter('manage_edit-products_columns', 'add_price_column');
function add_price_column($columns) {
    $columns['price'] = 'Price';
    return $columns;
}