/** * Get the contents of an ACF field. * * @param string $name The field name * @return mixed The field's data */ public function field($name) { foreach ($this->data as $post) { $fieldType = get_field_object($name, $post->ID)['type']; if (in_array($fieldType, ['text'])) { $post->{$name} = get_field($name, $post->ID); } elseif (in_array($fieldType, ['image'])) { $post->{$name} = Data::arrayToObject(get_field($name, $post->ID)); } } return $this->data; }