For posts (Posts, Pages and custom post types), the very first parameter for register_meta()
is always post
and to set a custom post type, use the object_subtype
argument in the third parameter like so:
$meta_args = array(
'object_subtype' => 'splash_location', // the post type
'type' => 'string',
'description' => 'A meta key associated with a string meta value.',
'single' => true,
'show_in_rest' => true,
);
register_meta( 'post', 'splash_location_title', $meta_args );
Or you could instead use register_post_meta()
which accepts the post type as the first parameter:
$meta_args = array(
'type' => 'string',
'description' => 'A meta key associated with a string meta value.',
'single' => true,
'show_in_rest' => true,
);
register_post_meta( 'splash_location', 'splash_location_title', $meta_args );
So in your existing code, you’d simply replace the register_meta
with register_post_meta
.. 🙂