The list_table_primary_column WordPress PHP Filter allows you to change the primary column for a specific list table in the WordPress admin area.
Usage
add_filter('list_table_primary_column', 'your_custom_function', 10, 2);
function your_custom_function($default, $context) {
// your custom code here
return $default;
}
Parameters
$default(string) – The default column name for the specific list table, e.g. ‘name’.$context(string) – The screen ID for a specific list table, e.g. ‘plugins’.
More information
See WordPress Developer Resources: list_table_primary_column
Examples
Change the primary column for plugins list table
This example sets the ‘Description’ column as the primary column for the plugins list table.
add_filter('list_table_primary_column', 'change_plugins_primary_column', 10, 2);
function change_plugins_primary_column($default, $context) {
if ($context === 'plugins') {
return 'description';
}
return $default;
}
Change the primary column for posts list table
Set the ‘Author’ column as the primary column for the posts list table.
add_filter('list_table_primary_column', 'change_posts_primary_column', 10, 2);
function change_posts_primary_column($default, $context) {
if ($context === 'edit-post') {
return 'author';
}
return $default;
}
Change the primary column for pages list table
Make the ‘Date’ column the primary column for the pages list table.
add_filter('list_table_primary_column', 'change_pages_primary_column', 10, 2);
function change_pages_primary_column($default, $context) {
if ($context === 'edit-page') {
return 'date';
}
return $default;
}
Change the primary column for comments list table
Set the ‘In Response To’ column as the primary column for the comments list table.
add_filter('list_table_primary_column', 'change_comments_primary_column', 10, 2);
function change_comments_primary_column($default, $context) {
if ($context === 'edit-comments') {
return 'response';
}
return $default;
}
Change the primary column for users list table
Make the ‘Email’ column the primary column for the users list table.
add_filter('list_table_primary_column', 'change_users_primary_column', 10, 2);
function change_users_primary_column($default, $context) {
if ($context === 'users') {
return 'email';
}
return $default;
}