Search

How to Add a Featured Image Column in Admin Dashboard

Listen to this article

add-column-wp-admin-panelI’m been working extensively on WordPress related development recently and have come across very interesting customization that you can incorporate into your WordPress system. I soon realised that i was unknowingly developing an interesting repository of techniques which can be used by others too. So, I decided to start writing about these tips and tricks to make it available to other fellow developers like myself.

Today, in this post I’m going to explain to you how to add a featured image column in admin dashboard. So, where exactly will this image be displayed to the users? Well, in the admin dashboard the users will be able to see the featured image on the all posts page. An extra column will be added to the table displaying the list of all posts on the website blog.

It will look something as below!

featured-image-column-list

Steps to Add a Featured Image Column in Admin Dashboard

Step 1: In order to make the featured image visible in the admin dashboard the first thing to do would be to set the featured image a blog post. The feature image can be added from the post page in the admin dashboard.

featured-image-column-post

Step 2: Now the user will have make changes to the functions.php file in order to make the featured image visible in the default listing of posts in the admin dashboard. The manage_posts_columns filter provided by WordPress will be used to achieve this result. This filter allows you to add columns to the list pages in the admin dashboard.

add_filter('manage_posts_columns', 'posts_columns');

Step 3: Along with this you will have to use the manage_posts_custom_column hook to name the column that is being added to the default post list in dashboard and to specify the size of the featured image thumbnail that will be displayed in the admin dashboard.

add_action('manage_posts_custom_column', 'posts_custom_columns');
    function posts_columns($defaults){
    $defaults['wdm_post_thumbs'] = __('Featured Image'); //name of the column
    return $defaults;
}
function posts_custom_columns($column_name, $id){
        if($column_name === 'wdm_post_thumbs'){
        echo the_post_thumbnail(array(100,100)); //size of the thumbnail 
    }
}

However the one thing to note here would be that if the theme is updated then the code that has just been added will be overridden.

Vivek Mengu

Vivek Mengu

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

WordPress Development

Custom WordPress Solutions, for You

LearnDash Development

Custom LearnDash Solutions, for You

WooCommerce Development

Custom WooCommerce Solutions, for You

WordPress Plugins

Scale your WordPress Business

WooCommerce Plugins

Scale your WooCommerce Business

LearnDash Plugins

Scale your LearnDash Business

Label

Title

Subtext

Label

Title

Subtext

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads