I’m attempting so as to add some customized meta variables to a customized publish kind, however I am unable to see the brand new variables after I dump a posts meta knowledge, and I am unable to entry it in
Right here is the publish definition from my features.php file
perform register_team_post(){
register_post_type('staff', [
'public'=>true,
'labels'=>array(
'name'=>'Team',
'add_new_item'=>'Add New Team Member',
'edit_item'=>'Edit Team Member',
'all_items'=>'All Team Member'
),
'menu_icon'=>'dashicons-businessman',
'show_in_rest' => true,
// 'supports' => array('editor','title', 'custom-fields'),
'supports' => array('editor','title'),
'rewrite' => array('slug' => 'teams'),
'template' => array(
array( 'dqcblocks/member' )
)
]);
$fields = [
'team_member_portrait',
'team_member_name',
'team_member_title',
'team_member_description'
];
$args = array('show_in_rest' => true, 'kind' => 'string');
foreach($fields as $discipline){
register_post_meta( 'staff', $discipline, $args);
}
}
add_action('init', 'register_team_post');
If I create a staff publish and tried dumping the meta fields, however my new fields do not seem:
$meta_values = get_post_meta( get_the_ID() );
var_dump( $meta_values );
end result:
array(2) {
["_edit_lock"]=>
array(1) {
[0]=>
string(12) "1566159392:1"
}
["_edit_last"]=>
array(1) {
[0]=>
string(1) "1"
}
}
I additionally tried utilizing my customized meta fields in a Gutenberg block.
attributes: {
portrait: {
kind: "string",
supply: "meta",
meta: "team_member_portrait",
},
identify: {
kind: "string",
supply: "meta",
meta: "team_member_name",
},
title: {
kind: "string",
supply : "meta",
meta: "team_member_title",
},
description: {
kind: "string",
supply: "meta",
meta: "team_member_description",
}
}
however after I add my block and save the variables do not replace and stay empty.
Am I utilizing register_post_meta appropriately?