1
我創建了一個名爲Members的自定義發佈類型。Wordpress自定義列
然後,我想爲此自定義帖子類型自定義顯示,以顯示已在列中輸入的一些自定義元。
列正在顯示,但數據沒有顯示,我不能解決原因。
add_filter('manage_edit-members_columns', 'my_columns_filter', 10, 1);
function my_columns_filter($columns) {
$column_phone = array('phone' => 'Phone Number');
$column_email = array('email' => 'Email Address');
$column_membertype = array('member_type' => 'Member Type');
$columns = array_slice($columns, 0, 2, true) + $column_phone + array_slice($columns, 2, NULL, true);
$columns = array_slice($columns, 0, 3, true) + $column_email + array_slice($columns, 3, NULL, true);
$columns = array_slice($columns, 0, 4, true) + $column_membertype + array_slice($columns, 4, NULL, true);
return $columns;
}
add_action('manage_members_custom_column', 'my_column_action', 10, 2);
function my_column_action($column, $post_id) {
global $post;
switch ($column) {
case 'phone':
echo get_post_meta($post_id, '_cricketss_phone', TRUE);
break;
case 'email':
echo get_post_meta($post_id, '_cricketss_email', TRUE);
break;
case 'member_type':
echo get_post_meta($post_id, '_cricketss_phone', TRUE);
break;
}
}
任何擡頭將不勝感激。
粘貼你的'register_post_type'代碼 – 2012-02-02 14:39:34