Quick post thumbnail check in WordPress Admin

The post thumbnail feature introduced in WordPress 2.9 is an absolute boon, but the WordPress core developers missed a small trick which would have made the use of post thumbnails even easier.

Wouldn’t it be good if you could go to the admin pages where you edit posts and pages and see at a glance which posts and pages have post thumbnails, without having to edit each one?

It’s actually very easy to add this feature to any WordPress theme, and this article explains exactly how to do it.

Resources

You’ll need a tick and a cross icon, to make for an easy visual check. Here are some suitable icons taken from the excellent Silk icon collection.

Download and copy them into your theme folder. I always keep theme images in a subfolder called images, so that’s the way my example will work.

Code

Now you’ve added the images to your theme, open your theme’s functions.php file in an editor. Go to the end of the file (though if it ends with ?> you should put the cursor before that) and paste in the following code block:

[php]
function my_custom_column_content($column)
{
if ($column == ‘featuredimage’)
{
global $post;
echo (has_post_thumbnail($post->ID)) ? ‘<img src="’.get_bloginfo(‘stylesheet_directory’).’/images/tick.png" alt="tick" title="Post has featured image" />’ : ‘<img src="’.get_bloginfo(‘stylesheet_directory’).’/images/bullet_cross.png" alt="cross" title="No featured image" />’ ;
}
}
add_action(‘manage_posts_custom_column’, ‘my_custom_column_content’);
add_action(‘manage_pages_custom_column’, ‘my_custom_column_content’);

function my_custom_column_setup($columns)
{
return array_merge($columns, array(‘featuredimage’=>’Image’));
}
add_filter(‘manage_edit-post_columns’, ‘my_custom_column_setup’);
add_filter(‘manage_edit-page_columns’, ‘my_custom_column_setup’);

function my_admin_head()
{
echo ‘<style type="text/css"> body.wp-admin table.wp-list-table .column-featuredimage { width:10%; } </style>’;
}
add_action(‘admin_head’, ‘my_admin_head’);
[/php]

This should give you the result shown in the screenshot at the top of this article, on both the posts and pages edit screens.

Just In Case

Don’t forget that you need to enable post thumbnails in your theme! The following snippet should do it. Paste into your functions file, somewhere before the above code block.

[php]
add_theme_support(‘post-thumbnails’, array(‘post’, ‘page’));
[/php]

Any problems, post a comment.

4 Comments

  1. Thank you so much for the tip. While I enjoy my WP blog, it is not also user friendly… checking thumbnails without having to edit the post saves a lot of time for me as I review several post a day. Thanks.

  2. Trivandrum team of seo guys loved this post.. thanks a ton. 🙂

  3. Thanks for this post. It gave us usefull information to work. You have done an amazing job!

  4. Real nice thumbnail checking tip, saves time and most of all, works!