Wordpress 用于推荐的自定义元框自定义帖子类型

Wordpress 用于推荐的自定义元框自定义帖子类型,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我有一个自定义的职位类型的推荐工作,就像我期望它。下面是推荐信的代码片段 add_action( 'init', 'register_cpt_testimonial' ); function register_cpt_testimonial() { ... $args = array( .. ); register_post_type( 'testimonial', $args ); } 然而,现在我想变得花哨,添加元框,但我无法让它显示

我有一个自定义的职位类型的推荐工作,就像我期望它。下面是推荐信的代码片段

add_action( 'init', 'register_cpt_testimonial' );
function register_cpt_testimonial() {

    ...

    $args = array( 
        ..
    );

    register_post_type( 'testimonial', $args );
}
然而,现在我想变得花哨,添加元框,但我无法让它显示出来

function testimonial_meta_boxes() {
    add_meta_box( 'testimonial_form', 'Testimonial Details', 'testimonial_form', 'testimonial', 'side', 'high' );
}

function testimonial_form() {
    $post_id = get_the_ID();
    $testimonial_data = get_post_meta( $post_id, '_testimonial', true );
    $client_name = ( empty( $testimonial_data['client_name'] ) ) ? '' : $testimonial_data['client_name'];

    wp_nonce_field( 'testimonial', 'testimonial' );
    ?>
    <p>
        <label>Client's Name (optional)</label><br />
        <input type="text" value="<?php echo $client_name; ?>" name="testimonial[client_name]" size="40" />
    </p>
    <?php
}
功能鉴定框(){
添加元框('Certional_form'、'Certional Details'、'Certional_form'、'Certional'、'side'、'high');
}
功能证明表格(){
$post_id=获取_id();
$estimonical_data=get_post_meta($post_id,'u estimonical',true);
$client_name=(空($commential_data['client_name'])?“”:$commential_data['client_name']);
wp_nonce_字段('commential','commential');
?>

客户名称(可选)

你必须添加这个钩子
add_动作('add_meta_box','commential_meta_box');


“管理”面板中未显示元数据库?
add_action('add_meta_boxes', 'testimonial_meta_boxes');

function testimonial_meta_boxes() {
   add_meta_box( 'testimonial_form', 'Testimonial Details', 'testimonial_form', 'testimonial', 'side', 'high' );
}