// add featured image thumbnail to admin
// Add the column to admin
function add_featured_image_column ( $columns ) {
return array_merge ( $columns, array (
'featured_image' => __ ( 'Featured Image' )
) );
}
add_filter ( 'manage_properties_posts_columns', 'add_featured_image_column' );
// Add featured image thumbnail to the column
add_action('manage_properties_posts_custom_column', 'display_thumbnail_column', 5, 2);
function display_thumbnail_column($column_name, $post_id){
switch($column_name){
case 'featured_image':
$post_thumbnail_id = get_post_thumbnail_id($post_id);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src( $post_thumbnail_id, 'thumbnail' );
echo '<img width="80" src="' . $post_thumbnail_img[0] . '" />';
}
break;
}
}
// Move custom column before "title" column
add_filter('manage_properties_posts_columns', 'cb_reorder_columns');
function cb_reorder_columns($columns) {
$n_columns = array();
$move = 'featured_image'; // which column to move
$before = 'title'; // move before this column
foreach($columns as $key => $value) {
if ($key==$before){
$n_columns[$move] = $move;
}
$n_columns[$key] = $value;
}
return $n_columns;
}