/**
* Add a "Featured Image" column to the Pages list in WordPress.
*/
function add_featured_image_column_to_pages( $columns ) {
// Insert a new column labeled 'Featured Image'
$columns['featured_thumb'] = __( 'Featured Image', 'your-textdomain' );
return $columns;
}
/**
* Display the featured image in our custom column.
*/
function display_featured_image_column_for_pages( $column, $post_id ) {
if ( 'featured_thumb' === $column ) {
// Get the ID of the featured image
$thumbnail_id = get_post_thumbnail_id( $post_id );
// If there's a featured image, display it (thumbnail size).
if ( $thumbnail_id ) {
$thumbnail = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail' );
if ( $thumbnail ) {
echo '';
}
} else {
echo __( 'No featured image', 'your-textdomain' );
}
}
}
add_filter( 'manage_pages_columns', 'add_featured_image_column_to_pages' );
add_action( 'manage_pages_custom_column', 'display_featured_image_column_for_pages', 10, 2 );