Show Featured Image in Your WordPress Admin Dashboard

When you are working with a WordPress theme that relies heavily on the use of a featured image, it is helpful having a visual guide showing where you have used them.

I am currently working on a site that uses the WordPress thumbnail as the background image in several places. It’s important that administrators can see whether a featured image has been set on Posts, Pages or custom post types, or some of the theme impact will be lost.

To make things easier, I wanted to show a thumbnail in the Admin dashboard of the featured image that had been set. Rather than use a plugin, I added some code to the functions.php in my theme. I found the code here on crunchify.com. I’m adding it below for my own convenience!

Quick note: Thanks to Laura at thepixelpixie.com for her debugging.

How to add a featured image to the WordPress admin list pages

Open up the functions.php file in your theme and add this code.


<?php
// show featured images in dashboard
add_image_size( 'haizdesign-admin-post-featured-image', 120, 120, false );
// Add the posts and pages columns filter. They both use the same function.
add_filter('manage_posts_columns', 'haizdesign_add_post_admin_thumbnail_column', 2);
add_filter('manage_pages_columns', 'haizdesign_add_post_admin_thumbnail_column', 2);
// Add the column
function haizdesign_add_post_admin_thumbnail_column($haizdesign_columns){
$haizdesign_columns['haizdesign_thumb'] = __('Featured Image');
return $haizdesign_columns;
}
// Manage Post and Page Admin Panel Columns
add_action('manage_posts_custom_column', 'haizdesign_show_post_thumbnail_column', 5, 2);
add_action('manage_pages_custom_column', 'haizdesign_show_post_thumbnail_column', 5, 2);
// Get featured-thumbnail size post thumbnail and display it
function haizdesign_show_post_thumbnail_column($haizdesign_columns, $haizdesign_id){
switch($haizdesign_columns){
case 'haizdesign_thumb':
if( function_exists('the_post_thumbnail') ) {
echo the_post_thumbnail( 'haizdesign-admin-post-featured-image' );
}
else
echo 'hmm… your theme doesn\'t support featured image…';
break;
}
}
?>

view raw

functions.php

hosted with ❤ by GitHub

You should now see a new column when viewing your Posts and Pages in list view:

featured image column

Add Column for Featured Images in WordPress

other page


7 Comments

  1. Laura

    Hi there,
    Your code has some errors. First, the apostrophes are curly and all have to be changed in your editor. Second, you’re missing brackets in your if statement near the end. Third and final, this eliminates all the other columns for the posts and pages instead of adding the image column.

    • Haiz Design

      Thanks very much Laura,
      I have updated the code. I have encoded this now so the apostrophes are correct and added the missing brackets. It was not eliminating the other other columns in any of the sites where I have added it, but again, thanks for Pixie-Debugging!

  2. John

    Excellent! Does exactly what I was hoping.

    I was a bit puzzled by the “haizdesign” code – but it works unedited on my website, so I won’t question it.

    Cheers!

  3. Gabriel

    Great tutorial! thank you!
    Quick question, how i can movie the column to be the first in line?

  4. Zé Barbosa

    It works, but… Doesn’t include the image settled as default featured image!

  5. Floyd

    Thanks for this excellent addition! Makes editing pages a snap now.

  6. momo-fr

    SAME QUESTION…

It's good to talk!

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