Just like the title says.
I am developing a theme and I need to add an extra column in WordPress > Admin > Posts with the post featured image.
Can someone help?
Thanks
Lucian Lucian Selected answer as best
Just like the title says.
I am developing a theme and I need to add an extra column in WordPress > Admin > Posts with the post featured image.
Can someone help?
Thanks
Pretty easy.
Just copy this code into your theme functions.php.
/* ================================================================================================================= prefix_column_image_heading - Add column heading Image in dashboard posts ================================================================================================================= */ function prefix_column_image_heading( $columns ) { if ( get_post_type() == 'post' ){ $columns['image'] = esc_attr__( 'Image','your-textdomain' ); return $columns; } } add_filter( 'manage_posts_columns', 'prefix_column_image_heading',1 ); /* ================================================================================================================= prefix_column_image - Add column image display in dashboard posts ================================================================================================================= */ function prefix_column_image( $column ) { if ( get_post_type() == 'post' ){ if ( $column === 'image') { if ( get_post_format() == false ){ if ( has_post_thumbnail() ){ $post_thumb = get_the_post_thumbnail_url( get_the_ID() ) ; echo '<img src=" '. esc_url( $post_thumb ) .' " class="admin-thumb">'; } } } } } add_action( 'manage_posts_custom_column', 'prefix_column_image',1 );
Login bellow or Register