Using WordPress ‘hidden_columns’ PHP filter

The hidden_columns WordPress PHP Filter allows you to modify the list of hidden columns in the WordPress admin screens.

Usage

add_filter('hidden_columns', 'your_custom_function', 10, 3);

function your_custom_function($hidden, $screen, $use_defaults) {
    // your custom code here
    return $hidden;
}

Parameters

  • $hidden (string[]): Array of IDs of hidden columns.
  • $screen (WP_Screen): WP_Screen object of the current screen.
  • $use_defaults (bool): Whether to show the default columns.

More information

See WordPress Developer Resources: hidden_columns

Examples

Hiding a specific column

Hiding the “Tags” column on the “Posts” screen.

add_filter('hidden_columns', 'hide_tags_column', 10, 3);

function hide_tags_column($hidden, $screen, $use_defaults) {
    if ('edit-post' === $screen->id) {
        $hidden[] = 'tags';
    }
    return $hidden;
}

Showing all columns

Force display all columns on the “Pages” screen.

add_filter('hidden_columns', 'show_all_columns', 10, 3);

function show_all_columns($hidden, $screen, $use_defaults) {
    if ('edit-page' === $screen->id) {
        return array();
    }
    return $hidden;
}

Hiding multiple columns

Hiding the “Author” and “Categories” columns on the “Posts” screen.

add_filter('hidden_columns', 'hide_multiple_columns', 10, 3);

function hide_multiple_columns($hidden, $screen, $use_defaults) {
    if ('edit-post' === $screen->id) {
        $hidden[] = 'author';
        $hidden[] = 'categories';
    }
    return $hidden;
}

Hiding a column for specific user roles

Hiding the “Comments” column on the “Posts” screen for “Subscriber” role.

add_filter('hidden_columns', 'hide_comments_column_for_subscribers', 10, 3);

function hide_comments_column_for_subscribers($hidden, $screen, $use_defaults) {
    if ('edit-post' === $screen->id && current_user_can('subscriber')) {
        $hidden[] = 'comments';
    }
    return $hidden;
}

Showing all columns except one

Force display all columns except the “Date” column on the “Media” screen.

add_filter('hidden_columns', 'show_all_columns_except_date', 10, 3);

function show_all_columns_except_date($hidden, $screen, $use_defaults) {
    if ('upload' === $screen->id) {
        return array('date');
    }
    return $hidden;
}