Support

Account

Home Forums General Issues How to populate all values even if it includes select

Solved

How to populate all values even if it includes select

  • I am using the following code to print all values of a specific field group by id…

    
    $group_ID = 228;
    $fields = array();
    $fields = apply_filters('acf/field_group/get_fields', $fields, $group_ID);
    
    if( $fields )
    {
    foreach( $fields as $field )
    {
    $value = get_field( $field['name'] );
    
    echo '<dl>';
    echo '<dt>' . $field['label'] . '</dt>';
    
    if ($field['type'] == 'select'){
    //What do I put in here to display values for multi select fields?
    
    } else {
    echo '<dd>' .$value . '</dd>';
    }
    
    echo '</dl>';
    }
    }
    

    …But I am lost to what I place within the ‘select’ conditional area to populate values that either have a single select value or multiple select values. No matter what I try, I get issues. My goal is to show all values for all the different types of of fields I have in my case.

    Just be clear, I have about 27 fields i’m working with and 8 of them are multi select fields in this mix. Meaning each of these 8 fields have multiple values the users can select.

    Thanks for any help!

  • 
    
    foreach( $fields as $field )
    {
    $value = get_field( $field['name'] );
    if (is_array($value)) {
      $value = implode(', ', $value);
    }
    
    echo '<dl>';
    echo '<dt>' . $field['label'] . '</dt>';
    echo '<dd>' .$value . '</dd>';
    echo '</dl>';
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘How to populate all values even if it includes select’ is closed to new replies.