get_field_object()
This function will return an array containing all the field data for a given field_name.
Хуков нет.
Возвращает
Массив|false
. $field
Использование
get_field_object( $selector, $post_id, $format_value, $load_value );
- $selector(строка) (обязательный)
- The field name or key.
- $post_id(разное)
- The post_id of which the value is saved against.
По умолчанию: false - $format_value(true|false)
- Whether to format the field value.
По умолчанию: true - $load_value(true|false)
- Whether to load the field value.
По умолчанию: true
Список изменений
С версии 3.6 | Введена. |
Код get_field_object() get field object ACF 6.0.4
function get_field_object( $selector, $post_id = false, $format_value = true, $load_value = true ) { // Compatibility with ACF ~4. if ( is_array( $format_value ) && isset( $format_value['format_value'] ) ) { $format_value = $format_value['format_value']; } $post_id = acf_get_valid_post_id( $post_id ); $field = acf_maybe_get_field( $selector, $post_id ); if ( ! $field ) { return false; } if ( $load_value ) { $field['value'] = acf_get_value( $post_id, $field ); } if ( $format_value ) { $field['value'] = acf_format_value( $field['value'], $post_id, $field ); } return $field; }