November 17, 2021
This affects all post types. Wrap in conditions to reduce appearance. Featured Image column will appear last.
function add_thumbnail_to_post_list_data($column,$post_id)
{
switch ($column)
{
case 'post_thumbnail':
echo '<a href="' . get_edit_post_link() . '">'.the_post_thumbnail( 'thumbnail' ).'</a>';
break;
}
}
function add_thumbnail_to_post_list( $columns )
{
$columns['post_thumbnail'] = 'Featured Image';
return $columns;
}
if (function_exists('add_theme_support'))
{
// Add To Posts
add_filter( 'manage_posts_columns' , 'add_thumbnail_to_post_list' );
add_action( 'manage_posts_custom_column' , 'add_thumbnail_to_post_list_data', 10, 2 );
// Add To Pages
add_filter( 'manage_pages_columns' , 'add_thumbnail_to_post_list' );
add_action( 'manage_pages_custom_column' , 'add_thumbnail_to_post_list_data', 10, 2 );
}
Reorder Featured Image to be first column:
function add_thumbnail_to_post_list( $columns )
{
//$columns['post_thumbnail'] = 'Thumbnail';
$columns = array_slice($columns, 0, 1, true) + array("post_thumbnail" => "Featured Image") + array_slice($columns, 1, count($columns) - 1, true);
return $columns;
}
Style:
add_action('admin_head', 'my_column_width');
function my_column_width() {
echo '<style type="text/css">';
echo '.column-mycolumn { text-align: center; width:60px !important; overflow:hidden }';
echo '</style>';
}
Source – setup with working image.
Source – ordering.
Source – style.