Display a custom column for featured image in the admin for a custom post list
Before you use this code you need that have a custom post type ‘gallery’, or you can edit the code to match your existing custom post type.
You also need to have the theme support for the post thumbnails ‘gallery-thumb’ and its size, so Copy the below code and paste it in the functions.php file.
add_theme_support('post-thumbnails', array( 'post', 'gallery')); //Add this line if it does not exist set_post_thumbnail_size(258, 112, true); //Add this line if it does not exist add_image_size('gallery-thumb', 162, 122, true); //Add this line
Copy the below code and paste it at the bottom of your functions.php file.
add_filter('manage_gallery_posts_columns', 'gallery_thumbs_columns', 5); add_action('manage_gallery_posts_custom_column', 'gallery_thumbs_custom_columns', 5, 2); function gallery_thumbs_columns($defaults){ $defaults['gallery_thumbs'] = __('Thumbnails'); return $defaults; } function gallery_thumbs_custom_columns($column_name, $id){ if($column_name === 'gallery_thumbs'){ echo the_post_thumbnail( 'gallery-thumb' ); } }