Field Render

Display a Currency selector as radio, checkbox or select field type.

Field Group

Field Settings

Setting nameDescription
Allow CurrenciesFilter which currencies can be chosen
AppearanceSelect the appearance of this field
Display FlagDisplay flags next to the currency name
Group by ContinentGroup currencies by their continent
Display FormatUse specific display format using template tags {symbol} {code} {name}
Default ValueEnter each default value on a new line
Return ValueReturn the currency array, currency name, currency code or currency symbol
Allow NullAllow empty value
LayoutChoose the layout
ToggleAllow to toggle all values
Allow Custom
Allow custom value
Save Custom
Save custom value in the field settings
Select multiple valuesAllow multiple values selection
Stylised UIEnable Select2 UI style

Field Value

Return Format: Currency Name

$currencies = get_field('currencies');

// United States Dollar

Return Format: Currency Code

$currencies = get_field('currencies');

// USD

Return Format: Currency Array

$currencies = get_field('currencies');

/**
 * array(
 *     'code'      => 'USD',
 *     'name'      => 'United States Dollar',
 *     'symbol'    => '$',
 *     'flag'      => 'us',
 *     'continent' => 'America',
 *     'countries' => array(
 *         'as',
 *         'ec',
 *         'fm',
 *         'gu',
 *         'kh',
 *         'mh',
 *         'mp',
 *         'pa',
 *         'pr',
 *         'pw',
 *         'sv',
 *         'tc',
 *         'tl',
 *         'us',
 *         'vg',
 *         'vi',
 *         'zw',
 *     ),
 *     'languages' => array(
 *         'en_US',
 *         'es_EC',
 *         'es_ES',
 *         'es_PR',
 *         'km',
 *         'pt_PT',
 *     ),
 * )
 */

Return Format: Currency Symbol

$currencies = get_field('currencies');

// $

Unformatted Value

$currencies = get_field('currencies', false, false);

// USD

Custom Query

/**
 * acfe/fields/currencies/query
 * 
 * @array        $args     Query arguments
 * @array        $field    Field settings
 * @bool/string  $post_id  Current Post ID
 */
filter('acfe/fields/currencies/query',                         $args, $field, $post_id);
filter('acfe/fields/currencies/query/name=my_currencies',      $args, $field, $post_id);
filter('acfe/fields/currencies/query/key=field_5ff50f25a59f6', $args, $field, $post_id);
add_filter('acfe/fields/currencies/query/name=my_currencies', 'my_acf_currencies_query', 10, 3);
function my_acf_currencies_query($args, $field, $post_id){
    
    // change orderby & order
    $args['orderby'] = 'name';
    $args['order'] = 'DESC';
    
    // return
    return $args;

}

Custom Result

/**
 * acfe/fields/currencies/result
 * 
 * @string       $text      Currency result
 * @array        $currency  Currency object
 * @array        $field     Field settings
 * @bool/string  $post_id   Current Post ID
 */
filter('acfe/fields/currencies/result',                         $text, $currency, $field, $post_id);
filter('acfe/fields/currencies/result/name=my_currencies',      $text, $currency, $field, $post_id);
filter('acfe/fields/currencies/result/key=field_5ff50f25a59f6', $text, $currency, $field, $post_id);
add_filter('acfe/fields/currencies/result/name=my_currencies', 'my_acf_currencies_result', 10, 4);
function my_acf_currencies_result($text, $currency, $field, $post_id){
    
    // change currency result
    $text = "<strong>{$text}</strong>";
    
    // return
    return $text;

}

PHP Query

It is possible to perform custom PHP queries and retrieve the result using the acfe_get_currencies() helper. Here are the default query arguments:

acfe_get_currencies(array(
    'code__in'      => false,
    'name__in'      => false,
    'continent__in' => false,
    'country__in'   => false,
    'language__in'  => false,

    'orderby'       => false,
    'order'         => 'ASC',
    'offset'        => 0,
    'limit'         => -1,

    'field'         => false,
    'display'       => false,
    'prepend'       => false,
    'append'        => false,
    'groupby'       => false,
));

Get single currency by code

$currency = acfe_get_currency('GBP');

/**
 * array(
 *     'code'      => 'GBP',
 *     'name'      => 'British pound',
 *     'symbol'    => '£',
 *     'flag'      => 'gb',
 *     'continent' => 'Europe',
 *     'countries' => array(
 *         'gb',
 *         'im',
 *         'je',
 *         'zw',
 *     ),
 *     'languages' => array(
 *         'cy',
 *         'en_GB',
 *         'en_US',
 *         'fr_FR',
 *         'gd',
 *     ),
 * )
 */

Get multiple currencies by code

$currencies = acfe_get_currencies(array(
    'code__in' => array('GBP')
));

/**
 * array(
 *     'GBP' => array(
 *         'code'      => 'GBP',
 *         'name'      => 'British pound',
 *         'symbol'    => '£',
 *         'flag'      => 'gb',
 *         'continent' => 'Europe',
 *         'countries' => array(
 *             'gb',
 *             'im',
 *             'je',
 *             'zw',
 *         ),
 *         'languages' => array(
 *             'cy',
 *             'en_GB',
 *             'en_US',
 *             'fr_FR',
 *             'gd',
 *         ),
 *     ),
 * )
 */

Get currencies by language

$currencies = acfe_get_currencies(array(
    'languages__in' => 'it_IT',
    'field'         => 'name',
    'limit'         => 3
));

/**
 * array(
 *     'EUR' => 'Euro',
 *     'CHF' => 'Swiss franc',
 * )
 */

Get currencies with custom display

$currencies = acfe_get_currencies(array(
    'code__in' => array('USD', 'EUR'),
    'field'    => 'code',
    'display'  => 'Code: {code} | Symbol: {symbol} | Flag: {flag}'
));

/**
 * array(
 *     'EUR' => 'Code: EUR | Symbol: € | Flag: eu',
 *     'USD' => 'Code: USD | Symbol: $ | Flag: us',
 * )
 */