I use ACF, created a group of fields, display all the data of arbitrary fields in a post.

var_dump(get_post_meta(88)) 

gives the following array:

 array(22) { ["_edit_last"]=> array(1) { [0]=> string(1) "1" } ["_edit_lock"]=> array(1) { [0]=> string(12) "1519921388:1" } ["protective_packing"]=> array(1) { [0]=> string(580) "text 1" } ["_protective_packing"]=> array(1) { [0]=> string(19) "field_5a97345fa9e31" } ["free_storage"]=> array(1) { [0]=> string(580) "text 2" } ["_free_storage"]=> array(1) { [0]=> string(19) "field_5a973b9d5dabb" } 

In this output, you can get the name of the field ["protective_packing"], for example, but how to get the label of the field, which is called "Protective packaging"?

    1 answer 1

    Use ACF functions.

     $field = get_field_object( 'protective_packing' ); 

    The function returns an array of the following form:

     array( 'ID' => 0, 'key' => '', 'label' => '', 'name' => '', 'prefix' => '', 'type' => 'text', 'value' => null, 'menu_order' => 0, 'instructions' => '', 'required' => 0, 'id' => '', 'class' => '', 'conditional_logic' => 0, 'parent' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '' ) ); 

    As I recall, the name you need will be in $field['label'] .

    Read more in the documentation .

    Update

    Here is the output of this function in the debugger:

    enter image description here

    • I tried this function, but it does NOT display the LABEL of an arbitrary field .... the shortcut is stored in the wp_postmeta table and looks like this: - Alexander
    • a: 13: {s: 3: "key"; s: 19: "field_5a97345fa9e31"; s: 5: "label"; s: 70: "Sealing and protective packaging of cargo"; s: 4: "name"; s : 18: "protective_packing"; s: 4: "type"; s: 8: "textarea"; s: 12: "instructions"; s: 0: ""; s: 8: "required"; s: 1: "0"; s: 13: "default_value"; s: 0: ""; s: 11: "placeholder"; s: 0: ""; s: 9: "maxlength"; s: 0: ""; s : 4: "rows"; s: 0: ""; s: 10: "formatting"; s: 2: "br"; s: 17: "conditional_logic"; a: 3: {s: 6: "status" ; s: 1: "0"; s: 5: "rules"; a: 1: {i: 0; a: 3: {s: 5: "field"; s: 4: "null"; s: 8 : "operator"; s: 2: "=="; s: 5: "value"; s: 0: "";}} s: 8: "allorany"; s: 3: "all";} s: 8: "order_no"; i: 0;} - Alexander
    • Can you tell me how to parse it? - Alexander
    • one
      Well, how it does not display when output? See, checked in the debugger: take.ms/SHid4 - KAGG Design