我知道的唯一方法是创建自己的列数组
// 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
}
希望这有帮助