Adding and populating custom columns in the WordPress post list table
The default WordPress post list table shows Title, Author, Categories, Tags, and Date. Adding your own columns — featured image, custom field value, taxonomy terms — makes bulk-reviewing content much faster.
Problem: How do you add a custom column to the WordPress admin post list table and fill it with meta data or a thumbnail?
Solution: Two hooks do the job: manage_{post_type}_posts_columns to register the column, and manage_{post_type}_posts_custom_column to populate it.
// 1. Add the column header
add_filter( 'manage_post_posts_columns', 'add_featured_image_column' );
function add_featured_image_column( $columns ) {
// Insert after the checkbox column
$new = [];
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;
if ( 'title' === $key ) {
$new['thumbnail'] = __( 'Thumbnail', 'textdomain' );
}
}
return $new;
}
// 2. Populate the column
add_action( 'manage_post_posts_custom_column', 'render_featured_image_column', 10, 2 );
function render_featured_image_column( $column, $post_id ) {
if ( 'thumbnail' !== $column ) return;
if ( has_post_thumbnail( $post_id ) ) {
echo get_the_post_thumbnail( $post_id, [ 60, 60 ] );
} else {
echo '—';
}
}
To make the column sortable by a custom field, add it to the sortable columns filter:
add_filter( 'manage_edit-post_sortable_columns', function( $cols ) {
$cols['thumbnail'] = 'thumbnail';
return $cols;
} );
NOTE: Replace post in the hook names with your custom post type slug to target a different post type. For example, manage_product_posts_columns for WooCommerce products.