Home › Forums › Feature Requests › How to Display multiple fields in just one php line? › Reply To: How to Display multiple fields in just one php line?
There isn’t any way to do what you’re looking for. There is get_field() that gets one value from one field https://www.advancedcustomfields.com/resources/get_field/ and there is get_field() that gets all the values for all the fields on a page https://www.advancedcustomfields.com/resources/get_fields/
If you want to get a list of specific fields then you’d need to call get_field() for each.
$field_names = array('field-name-1','field-name-2','field-name-3');
$fields = array();
foreach ($field_names as $field_name) {
$fields[$field_name] = get_field($field_name);
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.