I've defined some custom fields using Advanced Custom Fields, and I display these fields as keys and values using get_post_meta, e.g.:

<span class="campsite_meta_key">מחיר:</span>
<?php echo get_post_meta($post->ID, 'price', true);?>

<span class="campsite_meta_key">מפה:</span>
<?php echo get_post_meta($post->ID, 'map', true);?>

This involves code duplication, because the Hebrew name of the field (e.g. מפה) is already defined as the custom field label.

Is there a way to programmatically retrieve the a custom field label?


See the ACF documentation for get_field_object:

$field_object = get_field_object( 'price', $post->ID );
echo $field_object['label'];
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.