Post 编辑器中未显示 Wordpress 元字段

Wordpress Meta Fields Not Showing in Post Editor

对使用 WP 和自定义元字段有点陌生。

我正在尝试学习 REST API 并创建了一个插件来注册自定义元字段。这是插件:

/**
 * @package api_testing
 * @version 1.0.0
 */
/*
Plugin Name: API Testing
Plugin URI: http://example.com/
Description: The beginning of an awesome plugin
Author: Me
Version: 1.0.0
Author URI: http://example.com/
*/

function generate_press_type() {
    $labels = array(
        'name'                  => 'Press Articles',
        'singular_name'         => 'Press',
    );
    $args = array(
        'label'                 => 'Press',
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'custom-fields', 'thumbnail' ),
        'taxonomies'            => array( 'category', 'post_tag' ),
        'hierarchical'          => false,
        'public'                => true,
        'capability_type'       => 'post',
        'show_in_rest'          => true,
        'rest_base'             => 'press-articles',
        'rewrite'               => true,
        'rewrite_slug'          => '',        
    );
    register_post_type( 'press_article', $args );

    $meta_args = array(
        'type'         => 'string',
        'description'  => 'source',
        'single'       => true,
        'show_in_rest' => true,
    );

    register_post_meta( 'press_article', 'source', $meta_args );
    
}
add_action( 'init', 'generate_press_type', 0 );

我可以看到在 WP 后端输入“press”并创建 posts。当我查询它们时,元字段显示在有效负载中。我只是想知道是否可以让该字段显示在 Post 编辑器中,我看到了自定义字段列表,但不包括我的:

想知道我在注册 post 类型或元数据时是否遗漏了一个参数?我查看了文档,似乎我已经掌握了所有内容,但不确定...

您必须添加自定义元数据框才能显示该字段。请在此处查看 - https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/