The first version of my answer was that in general you would have to code that information yourself into the meta key itself. For example:
booking_date
booking_text
booking_number
But then I noticed the ACF tag of your question.
If you have a custom field key price
, then it’s ACF field key is saved to the hidden _price
custom field. For example as field_4fea85f5320da
.
Then you can use
get_field_object( $field_key, $post_id, $options )
to retrieve all the ACF information related to the custom field:
Array
(
[key] => field_4fea85f5320da
[label] => Text Field
[name] => text_field
[type] => text
[instructions] =>
[required] => 0
[default_value] =>
[formatting] => html
[order_no] => 0
[value] => Use the option parameter to toggle loading the value
)
Check the ACF documentation on get_field_object
here.
You could for example try to fetch it with:
$field_key = get_post_meta( '_price', TRUE );
if( ! empty( $field_key ) )
{
$data = get_field_object( $field_key, $post_id );
if( isset( $data['type'] ) )
$type = $data['type'];
}