The manage_posts_columns WordPress PHP filter allows you to modify the columns displayed in the Posts list table.
Usage
add_filter('manage_posts_columns', 'my_custom_columns', 10, 2); function my_custom_columns($post_columns, $post_type) { // your custom code here return $post_columns; }
Parameters
$post_columns
(array): An associative array of column headings.$post_type
(string): The post type slug.
More information
See WordPress Developer Resources: manage_posts_columns
Examples
Add a custom column
Add a new column named “Featured Image” to display the post’s featured image.
add_filter('manage_posts_columns', 'add_featured_image_column', 10, 2); function add_featured_image_column($post_columns, $post_type) { $post_columns['featured_image'] = __('Featured Image', 'textdomain'); return $post_columns; }
Remove an existing column
Remove the “Comments” column from the Posts list table.
add_filter('manage_posts_columns', 'remove_comments_column', 10, 2); function remove_comments_column($post_columns, $post_type) { unset($post_columns['comments']); return $post_columns; }
Reorder columns
Change the order of columns in the Posts list table.
add_filter('manage_posts_columns', 'reorder_post_columns', 10, 2); function reorder_post_columns($post_columns, $post_type) { $new_columns = array(); $new_columns['title'] = $post_columns['title']; $new_columns['author'] = $post_columns['author']; $new_columns['date'] = $post_columns['date']; return $new_columns; }
Add custom content to a new column
Display custom content, such as a custom field value, in a new “Custom Field” column.
add_filter('manage_posts_columns', 'add_custom_field_column', 10, 2); function add_custom_field_column($post_columns, $post_type) { $post_columns['custom_field'] = __('Custom Field', 'textdomain'); return $post_columns; } add_action('manage_posts_custom_column', 'display_custom_field_column_data', 10, 2); function display_custom_field_column_data($column, $post_id) { if ($column == 'custom_field') { $custom_field_value = get_post_meta($post_id, 'custom_field_key', true); echo $custom_field_value; } }
Modify column title
Change the title of the “Author” column to “Post Author”.
add_filter('manage_posts_columns', 'change_author_column_title', 10, 2); function change_author_column_title($post_columns, $post_type) { $post_columns['author'] = __('Post Author', 'textdomain'); return $post_columns; }