我已將一個新列添加到自定義帖子類型以顯示帖子的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;
}
}