我已将一个新列添加到自定义帖子类型以显示帖子的ID。这适用于WordPress核心帖子类型,但不适用于我的自定义帖子类型。我曾尝试使用manage_ {post_type} _custom_column挂钩,并将其应用于所有帖子,但都无效。自定义列不显示任何内容
它确实添加了自定义列标题,但在查看自定义帖子类型时,我无法用任何东西填充它们。
This is what it looks like when viewing the custom post type 和 this is what it looks like when viewing a regular core post.
// Add post ID column to use an order ID in all posts view.
add_filter('manage_posts_columns', 'oms_order_id_header');
add_action('manage_posts_custom_column', 'oms_order_id_column', 10, 2);
function oms_order_id_header($columns) {
//Remove title column
//unset($columns['title']);
//Add new columns
$columns['order_id_header'] = 'Order ID';
$columns['customer_header'] = 'Customer';
$columns['author'] = 'Owner';
return $columns;
}
function oms_order_id_column($column, $post_id) {
if ($column == 'order_id_header') {
echo $post_id;
}
}