Home Forums Front-end Issues If statement based on field type Reply To: If statement based on field type

  • Figured it out!!

    I took a chance and made an if statement based on what I thought was the radio button type (turned out to be ‘choices’) and it actually worked.
    Here’s the code i used. So this calls all fields within a group, takes out any that doesn’t have a value, then puts an icon instead of a ‘yes or ‘no’ for the radio button, yet keeps all other fields loading like they normally do:

    $group_ID = 6817;
    $fields = array();
    $fields = apply_filters('acf/field_group/get_fields', $fields, $group_ID);
    if( $fields )
      foreach( $fields as $field_name => $field )
        $value = get_field( $field['name'] );
        if ($field['choices']){
          $map = array(
           'yes' => '<i class="icon-ok"></i>',
            'no' => '<i class="icon-remove"></i>'
          $value = $map[ $value ];
        } else {
        if( $value ) {
          echo '<li><b> ' . $field['label'] . '</b> ' . $value . '</li>';