Using WordPress ‘get_column_headers()’ PHP function

The get_column_headers() WordPress PHP function retrieves the column headers for a specific screen.

Usage

To use the function, simply provide the screen name as a string or a WP_Screen object.

get_column_headers($screen);

Parameters

  • $screen (string|WP_Screen) – The screen you want the headers for.

More information

See WordPress Developer Resources: get_column_headers()

Examples

Get column headers for a custom post type

Retrieve the column headers for a custom post type named “books”.

$screen = 'edit-books';
$headers = get_column_headers($screen);
print_r($headers);

Get column headers for the plugins screen

Retrieve the column headers for the plugins screen.

$screen = 'plugins';
$headers = get_column_headers($screen);
print_r($headers);

Get column headers for the users screen

Retrieve the column headers for the users screen.

$screen = 'users';
$headers = get_column_headers($screen);
print_r($headers);

Get column headers for the themes screen

Retrieve the column headers for the themes screen.

$screen = 'themes';
$headers = get_column_headers($screen);
print_r($headers);

Get column headers for a WP_Screen object

Retrieve the column headers for a WP_Screen object, like the current screen.

$current_screen = get_current_screen();
$headers = get_column_headers($current_screen);
print_r($headers);