How To Add A Featured Image Column Inside The Admin Post List

Featured images are an important part of any WordPress website. They help to make your posts and pages more visually appealing and can also help to improve your SEO.

By default, WordPress does not display the featured image in the admin post list. However, there is a simple way to add a featured image column to the admin post list. This can be useful for quickly seeing which posts have featured images and for making it easier to edit featured images.

Step 1: Add the Code to Your Functions.php File

To add a featured image column to the admin post list, you will need to add some code to your child theme’s functions.php file.

add_filter( 'manage_posts_columns', function ( $columns ) {
    $columns['featured_image'] = __( 'Featured Image' );
    return $columns;
} );

add_action( 'manage_posts_custom_column', function ( $column_name, $post_id ) {
    if ( $column_name === 'featured_image' ) {
        $thumbnail_id = get_post_thumbnail_id( $post_id );
        $thumbnail_url = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail' );
        $thumbnail_html = '<img src="' . $thumbnail_url[0] . '" alt="' . get_the_title( $post_id ) . '" width="100" />';
        echo $thumbnail_html;
    }
} );

Step 2: Make Sure that the only_run_in_admin Filter is Set to true

The only_run_in_admin filter ensures that the code is only executed in the admin area. This is important because we don’t want to display the featured image column on the front end of your website.

To make sure that the only_run_in_admin filter is set to true, you can add the following code to your child theme’s functions.php file:

add_filter( 'only_run_in_admin', '__return_true' );

Step 3: Save Your Changes and Activate Your Child Theme

Once you have added the code to your child theme’s functions.php file and saved your changes, you need to activate your child theme.

To do this, go to Appearance > Themes in your WordPress dashboard and click the Activate button next to your child theme.

Once you have activated your child theme, you should see a new column labeled “Featured Image” in the admin post list. This column will display the featured image for each post.

Tips

  • You can change the position of the featured image column by changing the order of the $columns array in the add_filter() function.
  • You can change the size of the featured image by changing the second argument to the wp_get_attachment_image_src() function.
  • You can also add additional custom columns to the admin post list using the same approach.

Note: You can use any code manager Plugin Like Code snippets, WP Code, etc that allows you to add PHP snippets to your website.

You should run this snippet on the admin area only as this is not needed in the front end of the website. So, it won’t impact the Speed performance of your website and you will be able to use it without any worry.

By following this article, You will be able to add a featured image column to your WordPress Admin Post List area. If you have any doubts, you can ask me in the comment section.

Conclusion

Adding a featured image column to the admin post list is a simple way to make it easier to manage and edit your featured images. It is also a great way to quickly see which posts have featured images.

In this way, You will be able to see the featured images used on the blog post right within the admin area of your WordPress website.

My name is Megha, A computer science student with a passion for digital marketing and SEO, enjoys helping beginners build impressive WordPress websites.

Leave a Comment