我创建了一个名为 Members 的自定义帖子类型。
然后,我想自定义此自定义帖子类型的显示以显示已在列中输入的一些自定义元数据。
列正在显示,但数据没有显示,我不知道为什么。
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;
}
}
任何抬头将不胜感激。