reference post's existing custom fields
I was hoping to simply replace WP's custom fields with CF. I have existing post meta data on an old site that I am currently accessing via get_post_meta(). I was hoping that I could simply create Carbon fields via Field::make(‘text’, ‘client’) and it would reference this existing post data.
Here is how I am currently accessing the existing metadata
get_post_meta($post->ID, 'client', true);
Here is my code:
Container::make('post_meta', 'Project Info')
->where('post_type', '=', 'project')
->add_fields([
Field::make('text', 'client'),
]);
I see that I can access the carbon meta with
get_post_meta($post->ID, '_client', true);
But I need to access the existing ‘client’ meta not ‘_client’. Is this possible?
If you're comfortable working with SQL you can always migrate your old data; for example:
UPDATE `wp_postmeta` SET `meta_key`='_crb_client' WHERE `meta_key` = 'client';
I'm sure there a logical reason for this but it would really nice if there was an option to use existing field names without having to recreate them. A flag or filter that would not add the underscore to the meta name.
Chiming in here with a partial answer. The underscore in front of the meta key name has the effect of hiding both the key and the value from the default (classic editor) Custom Fields meta box.

Moving forward into the 5.0 era of WP, this won't be much of a factor. And if you are 100% committed to Gutenberg in your theme, I'd venture that you can safely run the above SQL query to get rid of the underscore completely.