Localized Number Shortcode
Adds a [wpide_number] shortcode that prints a number with the thousands and decimal separators of the current language, for example 1,234.5 or 1.234,5.
Opens WPIDE on
Code
add_shortcode( 'wpide_number', function ( $atts ) {
$atts = shortcode_atts( array( 'value' => 0, 'decimals' => 0 ), $atts, 'wpide_number' );
return esc_html( number_format_i18n( (float) $atts['value'], min( 6, absint( $atts['decimals'] ) ) ) );
} );
Notes
Use [wpide_number value="1234.5" decimals="1"].
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.