Home / admin / Updated: Add featured thumbnail to admin post / page columns
  • How to Updated: Add featured thumbnail to admin post / page columns

    updated-add-featured-thumbnail-to-admin-post-page-columns

    This is an updated version of the posts thumbnail column snippet. Adding this snippet to the functions.php of your wordpress theme will add a new thumbnail column to your posts and pages admin columns.

    Just a few updates to this including one courtesy of Cliff Paulick's suggestion to check if post thumbnails are supportsed first to avoid errors. I also define a default image size and of course included both posts and pages in this snippet. ( example screenshot ) ( click code to copy )

    wordpress snippet : PHP

    <>
    if (function_exists( 'add_theme_support' )){
        add_filter('manage_posts_columns', 'posts_columns', 5);
        add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
        add_filter('manage_pages_columns', 'posts_columns', 5);
        add_action('manage_pages_custom_column', 'posts_custom_columns', 5, 2);
    }
    function posts_columns($defaults){
        $defaults['wps_post_thumbs'] = __('Thumbs');
        return $defaults;
    }
    function posts_custom_columns($column_name, $id){
    	if($column_name === 'wps_post_thumbs'){
            echo the_post_thumbnail( array(125,80) );
        }
    }
    

    ( WordPress codex functions, hooks, in this snippet. )

    manage_posts_columns, manage_pages_columns, the_post, add_filter, add_action, add_theme_support, __, _n, _e, _ex, wp,