# Localized Currency Amount Shortcode

> Adds a [wpide_money] shortcode that formats an amount in a currency using the conventions of the current language, like $1,234.50, 1.234,50 € or ¥1,235.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: currency, locale, shortcode
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/i18n-localized-price-shortcode/

## Code

```php
add_shortcode( 'wpide_money', function ( $atts ) {
    $atts     = shortcode_atts( array( 'amount' => 0, 'currency' => 'USD' ), $atts, 'wpide_money' );
    $amount   = (float) $atts['amount'];
    $currency = strtoupper( preg_replace( '/[^A-Za-z]/', '', $atts['currency'] ) );

    if ( class_exists( 'NumberFormatter' ) ) {
        $formatter = new NumberFormatter( determine_locale(), NumberFormatter::CURRENCY );
        $output    = $formatter->formatCurrency( $amount, $currency );
        if ( false !== $output ) {
            return esc_html( $output );
        }
    }

    return esc_html( $currency . ' ' . number_format_i18n( $amount, 2 ) );
} );
```

## Notes

Use [wpide_money amount="1234.5" currency="EUR"]. Needs PHP's intl extension for full formatting; without it a simple fallback is used.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Localized Currency Amount Shortcode" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
