主要错误是$post_ID
中的参数page_template_field
和使用$custom_field_id
而不是$post_ID
.
无论如何,这是可行的,而且更简单:
add_filter(\'manage_pages_columns\', \'column_page\');
function column_page($defaults) {
$defaults[\'column_template\'] = \'Page Template\';
return $defaults;
}
add_action(\'manage_pages_custom_column\',\'column_page_template\',10,2);
function column_page_template($column_name, $post_ID) {
if ($column_name == \'column_template\') {
$custom_field_values = get_post_meta($post_ID,\'page_template\');
if (!empty($custom_field_values)) {
echo \'<p> \'. join(\', \',$custom_field_values) .\' </p>\';
}
}
}