get_fields() ACF 3.6
This function will return an array containing all the custom field values for a specific post_id. The function is not very elegant and wastes a lot of PHP memory / SQL queries if you are not using all the values.
Хуков нет.
Возвращает
(Массив) associative. array where field name => field value
Использование
get_fields( $post_id, $format_value );
- $post_id **
- -
По умолчанию: false - $format_value **
- -
По умолчанию: true
Список изменений
С версии 3.6 | Введена. |
Код get_fields() get fields ACF 5.9.1
function get_fields( $post_id = false, $format_value = true ) {
// vars
$fields = get_field_objects( $post_id, $format_value );
$meta = array();
// bail early
if( !$fields ) return false;
// populate
foreach( $fields as $k => $field ) {
$meta[ $k ] = $field['value'];
}
// return
return $meta;
}