acf_get_meta_field()
acf_get_meta_field
Returns a field using the provided $id and $post_id parameters. Looks for a reference to help loading the correct field via name.
No Hooks.
Returns
(Array|false). The field array.
Usage
acf_get_meta_field( $key, $post_id );
- $key(string)
- The meta name (field name).
- $post_id((int|string))
- The post_id where this field's value is saved.
Changelog
| Since 5.7.10 | Introduced. |
acf_get_meta_field() acf get meta field code ACF 6.8.8
function acf_get_meta_field( $key = 0, $post_id = 0 ) {
// Try reference.
$field_key = acf_get_reference( $key, $post_id );
if ( $field_key ) {
$field = acf_get_field( $field_key );
if ( $field ) {
$field['name'] = $key;
return $field;
}
}
// Return false.
return false;
}