mkwebworker
10/10/2013 - 11:28 AM

Add a custom column with post thumbnail to the post overview

Add a custom column with post thumbnail to the post overview

/* Add the post thumbnail to admin panel - marcokuemmel.de*/
function my_custom_column_content($column)
	{
	if ($column == 'featuredimage')
		{
		global $post;
		echo (has_post_thumbnail($post->ID)) ? the_post_thumbnail(array(80,80)) : '<p>kein Bild festgelegt</p>' ;
		}
	}
// for cpt use manage_{$post_type}_posts_custom_column
add_action('manage_posts_custom_column', 'my_custom_column_content');

function my_custom_column_setup($columns)
	{
	return array_merge($columns, array('featuredimage'=>'Artikelbild'));
	}
// replace posts with name of the post type to add the column on other post types	
add_filter('manage_edit-posts_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');