Wordpress自定义列

Wordpress自定义列,wordpress,custom-post-type,customcolumn,Wordpress,Custom Post Type,Customcolumn,我已经创建了一个名为Members的自定义帖子类型 然后,我想为这个自定义帖子类型定制显示,以显示一些在列中输入的自定义元 列正在显示,但数据没有显示,我不知道为什么 add_filter( 'manage_edit-members_columns', 'my_columns_filter', 10, 1 ); function my_columns_filter( $columns ) { $column_phone = array( 'phone' => 'Phone Number'

我已经创建了一个名为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;
}
}

任何提示都将不胜感激。

我将在没有注册后类型代码的情况下试一试。以下是一些可以尝试的东西

如果尚未将“hierarchical”=>false添加到您的register\u post\u类型中

改变

add_action( 'manage_members_custom_column', 'my_column_action', 10, 2 );

add_action( 'manage_posts_custom_column', 'my_column_action', 10, 2 );
我有一种强烈的感觉,你的问题在于我提到的第二点

各国:

与manage_edit-${post_type}\u columns过滤器结合使用,可以将自定义列添加到post/page/custom post type页面列表中。这里描述的过滤器既适用于内置帖子类型,也适用于自定义帖子类型。请注意,如果自定义帖子类型具有'hierarchical'=>true,则要使用的正确操作挂钩是manage\u pages\u custom\u column。

粘贴您的注册帖子类型代码