これを試して :
/* === Add Thumbnails to Posts/Pages List === */
if ( !function_exists('o99_add_thumbs_column_2_list') && function_exists('add_theme_support') ) {
// // set your post types , here it is post and page...
add_theme_support('post-thumbnails', array( 'post', 'page' ) );
function o99_add_thumbs_column_2_list($cols) {
$cols['thumbnail'] = __('Thumbnail');
return $cols;
}
function o99_add_thumbs_2_column($column_name, $post_id) {
$w = (int) 60;
$h = (int) 60;
if ( 'thumbnail' == $column_name ) {
// back comp x WP 2.9
$thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
// from gal
$attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
if ($thumbnail_id)
$thumb = wp_get_attachment_image( $thumbnail_id, array($w, $h), true );
elseif ($attachments) {
foreach ( $attachments as $attachment_id => $attachment ) {
$thumb = wp_get_attachment_image( $attachment_id, array($w, $h), true );
}
}
if ( isset($thumb) && $thumb ) {
echo $thumb;
} else {
echo __('None');
}
}
}
// for posts
add_filter( 'manage_posts_columns', 'o99_add_thumbs_column_2_list' );
add_action( 'manage_posts_custom_column', 'o99_add_thumbs_2_column', 10, 2 );
// for pages
add_filter( 'manage_pages_columns', 'o99_add_thumbs_column_2_list' );
add_action( 'manage_pages_custom_column', 'o99_add_thumbs_2_column', 10, 2 );
}
投稿の管理/ページリストにプレビューとして注目の画像が表示されます。投稿自体の中に表示したい場合は、@ Calleの提案を使用してください:(ここで機能するように変更)
add_action( 'add_meta_boxes', 'o99_add_attach_thumbs_meta_b' );
function o99_add_attach_thumbs_meta_b (){
add_meta_box ('att_thumb_display', 'Attached images','o99_render_attach_meta_b','post');
}
function o99_render_attach_meta_b( $post ) {
$output = '';
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post->ID
);
//
// uncomment if you want ordered list
//
// $output .= '<ul>';
$images = get_posts( $args );
foreach( $images as $image) {
//$output .= '<li>';
$output .= '<img src="' . wp_get_attachment_thumb_url( $image->ID ) . '" />';
//$output .= '</li>';
}
// $output .= '</ul>';
echo $output;
}