Filters the column headers for a list table on a specific screen.
Description
The dynamic portion of the hook name, $screen->id
, refers to the ID of a specific screen. For example, the screen ID for the Posts list table is edit-post, so the filter for that screen would be manage_edit-post_columns.
Parameters
$columns
string[]- The column header labels keyed by column ID.
Source
$column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() );
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
Example migrated from Codex:
Add Columns
Suppose you have a ‘books’ custom post type and you want to add the publisher and book author to the list of columns.
Replace Columns
Here’s another example that removes and replaces some of the columns.
Note that unlike an
array
data type, theunset
PHP function accepts arguments in which the last argument should NOT end with a comma.Hide Columns
Here is an example of how to remove or (hide) columns from Pages / Posts and Custom Post Types without adding any.
You can also add the name of the custom-post type and filter them out in there too… But if you have 5 custom post types you will need five different filters.
Note: Replace the text CUSTOMPOSTTYPE below with the name of your post type.
Example migrated from Codex:
Add an extra column to the users table:
We need to care while using
manage_{$screen->id}_columns
hook formedia
screen because when we usedmanage_media_columns
hook we will receive Too few arguments fatal error in Add New Media File page error.This error is coming because in the 'manage_media_columns' filter hook in wp-admin/includes/class-wp-media-list-table.php passes two arguments.
Hook Details : https://developer.wordpress.org/reference/hooks/manage_media_columns/