Add Featured Post Thumbnails to WordPress Admin Post Columns

How to Add Featured Post Thumbnails to WordPress Admin Post Columns

in WordPress Admin
Google+ LinkedIn

Have you ever wanted to see the featured post thumbnails associated with your posts, without going through each post individually? Wouldn’t it be nice if you can see all post thumbnails while viewing the list of posts in the WordPress admin? If you want this feature to add in your website then you are in luck because we just have a perfect solution for you. We have a code snippet that does just that by adding an additional column to the list of posts and pages in WordPress admin and displays the featured post thumbnails in it.

WordPress filters mange_posts_columns and manage_posts_custom_column allow us to add custom columns to the list of post & pages in the WordPress admin. These two filters control which columns should be displayed when a user views the list of posts or pages. So we used these functions to add an additional column to the list of posts and pages for displaying featured post thumbnails. You can add this code snippet in your functions.php file of your current theme.

// add featured thumbnail to admin post columns
function wpcs_add_thumbnail_columns( $columns ) {
    $columns = array(
        'cb' => '<input type="checkbox" />',
        'featured_thumb' => 'Thumbnail',
        'title' => 'Title',
        'author' => 'Author',
        'categories' => 'Categories',
        'tags' => 'Tags',
        'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>',
        'date' => 'Date'
    );
    return $columns;
}

function wpcs_add_thumbnail_columns_data( $column, $post_id ) {
    switch ( $column ) {
    case 'featured_thumb':
        echo '<a href="' . get_edit_post_link() . '">';
        echo the_post_thumbnail( 'thumbnail' );
        echo '</a>';
        break;
    }
}

if ( function_exists( 'add_theme_support' ) ) {
    add_filter( 'manage_posts_columns' , 'wpcs_add_thumbnail_columns' );
    add_action( 'manage_posts_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
    add_filter( 'manage_pages_columns' , 'wpcs_add_thumbnail_columns' );
    add_action( 'manage_pages_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
}

This is a very handy code snippet if you use post thumbnail feature very heavily and don’t want to have to edit each post in order to see the thumbnail being used.

Share the love

If you like this snippet, share it with others!

4 Replies on "Add Featured Post Thumbnails to WordPress Admin Post Columns"

  1. Nasim Firoz

    Hi ! Nick Fisher. I want to change the Thumbnail size into 80 X 80 pixel . How to do this.

    1. Hi Nasim,

      Thank you for stopping by. You can change that by defining your own custom thumbnail size and replace it’s handle in above code in place of ‘thumbnail’. in this particular piece of code.

      echo the_post_thumbnail( 'thumbnail' );
      1. web dev blog

        Its will change all thumbnail size ?

      2. @Web dev blog

        No. It will not change thumbnail sizes.

Leave a Reply

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