วิธีเดียวที่ฉันรู้วิธีสร้างคอลัมน์ของคุณเอง
// Add to admin_init function
add_filter('manage_edit-au-gallery_columns', 'add_my_gallery_columns');
function add_my_gallery_columns($gallery_columns) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['id'] = __('ID');
$new_columns['title'] = _x('Gallery Name', 'column name');
// your new column somewhere good in the middle
$new_columns['thumbnail'] = __('Thumbnail');
$new_columns['categories'] = __('Categories');
$new_columns['tags'] = __('Tags');
$new_columns['date'] = _x('Date', 'column name');
return $new_columns;
}
จากนั้นสร้างคอลัมน์ที่เพิ่มพิเศษนี้ตามปกติ
// Add to admin_init function
add_action('manage_au-gallery_posts_custom_column', 'manage_gallery_columns', 10, 2);
function manage_gallery_columns($column_name, $id) {
global $wpdb;
switch ($column_name) {
case 'id':
echo $id;
break;
case 'Thumbnail':
$thumbnail_id = get_post_meta( $id, '_thumbnail_id', true );
// image from gallery
$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($width, $height), true );
elseif ($attachments) {
foreach ( $attachments as $attachment_id => $attachment ) {
$thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
}
}
if ( isset($thumb) && $thumb ) {echo $thumb; } else {echo __('None');}
break;
default:
break;
} // end switch
}
หวังว่าสิ่งนี้จะช่วย