我添加了一个自定义post类型,我想在rest api中公开自定义字段值。根据文档,可以使用register\\u meta。
我用wordpress的方式创建了一个自定义的post meta框。它工作正常,但没有显示在RESTAPI中。我相信我必须通过数组

add_action( \'rest_api_init\', \'qrcode_register_posts_meta_field\' );
function qrcode_register_posts_meta_field(){
$meta_args = array( // Validate and sanitize the meta value.
\'type\' => \'array\',
\'description\' => \'A meta key associated with a string meta value.\',
\'single\' => true,
\'show_in_rest\' => array(
\'schema\'=> array(
\'type\'=> \'array\',
\'items\'=> array(
\'type\'=> \'string\',
),
),
),
);
register_meta( \'post\', \'qrcode_qr-code-type\', $meta_args );
}