Created
January 8, 2026 00:57
-
-
Save ofernandolopes/35bf6f787b907ad26d5d85586ece970c to your computer and use it in GitHub Desktop.
Add the featured image column in admin columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add the featured image column | |
| function rudr_featured_image_column( $cols ) { | |
| $cols = array_slice( $cols, 0, 1, true ) + array( 'featured_image' => 'Image' ) + array_slice( $cols, 1, NULL, true ); | |
| return $cols; | |
| } | |
| add_filter( 'manage_posts_columns', 'rudr_featured_image_column' ); | |
| add_filter( 'manage_pages_columns', 'rudr_featured_image_column' ); // Add for pages | |
| // Fill the column with the featured image | |
| function rudr_render_the_column( $column_name, $post_id ) { | |
| if ( 'featured_image' === $column_name ) { | |
| echo get_the_post_thumbnail( $post_id, array( 60, 60 ) ); // Adjust image size here | |
| } | |
| } | |
| add_action( 'manage_posts_custom_column', 'rudr_render_the_column', 10, 2 ); | |
| add_action( 'manage_pages_custom_column', 'rudr_render_the_column', 10, 2 ); // Add for pages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment