Can’t set custom meta fields for a post

I am trying to add some custom meta variables to a custom post type, but I can’t see the new variables when I dump a posts meta data, and I can’t access it in

Here is the post definition from my functions.php file

function register_team_post(){
register_post_type(‘team’, [
‘add_new_item’=>’Add New Team Member’,
‘edit_item’=>’Edit Team Member’,
‘all_items’=>’All Team Member’
‘show_in_rest’ => true,
// ‘supports’ => array(‘editor’,’title’, ‘custom-fields’),
‘supports’ => array(‘editor’,’title’),
‘rewrite’ => array(‘slug’ => ‘teams’),
‘template’ => array(
array( ‘dqcblocks/member’ )

$fields = [

$args = array(‘show_in_rest’ => true, ‘type’ => ‘string’);

foreach($fields as $field){
register_post_meta( ‘team’, $field, $args);

add_action(‘init’, ‘register_team_post’);

If I create a team post and tried dumping the meta fields, but my new fields don’t appear:

$meta_values = get_post_meta( get_the_ID() );
var_dump( $meta_values );


array(2) {
array(1) {
string(12) “1566159392:1”
array(1) {
string(1) “1”

I also tried using my custom meta fields in a Gutenberg block.

attributes: {
portrait: {
type: “string”,
source: “meta”,
meta: “team_member_portrait”,
name: {
type: “string”,
source: “meta”,
meta: “team_member_name”,
title: {
type: “string”,
source : “meta”,
meta: “team_member_title”,
description: {
type: “string”,
source: “meta”,
meta: “team_member_description”,

but when I add my block and save the variables don’t update and remain empty.

Am I using register_post_meta correctly?

Read more here:: Can’t set custom meta fields for a post

Leave a Reply

Your email address will not be published. Required fields are marked *