Support

Account

Home Forums Backend Issues (wp-admin) Custom field types: saving and loading values Reply To: Custom field types: saving and loading values

  • It would be something that simple, wouldn’t it! Below is what I ended up using:

    
    $attrs = array(
        'id'      => $field['id'],
        'name'    => $field['name'],
    );
    
    ?>
    
    <select <?php echo implode( ' ', array_map(function($val, $key) { return sprintf( '%1$s="%2$s"', $key, esc_attr($val) ); }, $attrs, array_keys( $attrs ))); ?>>
    
        <?php
    
        foreach ($languages as $language) {
    
            ?><option value=<?php echo '"' . $language['tag'] . '"'; if($language['tag'] == $field['value']): ?> selected="selected"<?php endif; ?>><?php echo $language['name']; ?></option><?php
    
        }
    
        ?>
    
    </select>
    

    Credit to https://github.com/nlemoine/acf-country.