acf_get_field()
acf_get_field
Retrieves a field for the given identifier.
Хуки из функции
Возвращает
(Массив|false)
. The field array.
Использование
acf_get_field( $id );
- $id((int|string))
- The field ID, key or name.
Список изменений
С версии 5.7.10 | Введена. |
Код acf_get_field() acf get field ACF 6.0.4
function acf_get_field( $id = 0 ) { // Allow WP_Post to be passed. if ( is_object( $id ) ) { $id = $id->ID; } // Check store. $store = acf_get_store( 'fields' ); if ( $store->has( $id ) ) { return $store->get( $id ); } // Check local fields first. if ( acf_is_local_field( $id ) ) { $field = acf_get_local_field( $id ); // Then check database. } else { $field = acf_get_raw_field( $id ); } // Bail early if no field. if ( ! $field ) { return false; } // Validate field. $field = acf_validate_field( $field ); // Set input prefix. $field['prefix'] = 'acf'; /** * Filters the $field array after it has been loaded. * * @date 12/02/2014 * @since 5.0.0 * * @param array The field array. */ $field = apply_filters( 'acf/load_field', $field ); // Store field using aliasses to also find via key, ID and name. $store->set( $field['key'], $field ); $store->alias( $field['key'], $field['ID'], $field['name'] ); // Return. return $field; }