// 1. Add Thumbnail Column Header
add_filter( 'manage_posts_columns', function( $columns ) {
$new_cols = [];
foreach ( $columns as $key => $title ) {
if ( 'title' === $key ) {
$new_cols['tipwp_thumb'] = __( 'Image', 'tipwp' );
}
$new_cols[$key] = $title;
}
return $new_cols;
} );
// 2. Render Thumbnail in Column
add_action( 'manage_posts_custom_column', function( $column, $post_id ) {
if ( 'tipwp_thumb' === $column ) {
if ( has_post_thumbnail( $post_id ) ) {
echo get_the_post_thumbnail( $post_id, [ 48, 48 ], [ 'style' => 'border-radius: 4px; object-fit: cover;' ] );
} else {
echo '<span style="color:#a1a1aa;font-size:11px;">No Image</span>';
}
}
}, 10, 2 );