Format numbers
Format a custom field number with a custom shortcode
This custom shortcode outputs a custom field number, typed as 12000,355 for the following usage example.
It has 4 attributes to specifiy the number source (custom field key), the number of decimals to display, the decimal separator and the thousands separator:
- number
- decimals
- dec_point
- thousands_sep
12,000.355
3 decimals, period for decimals and comma for thousands separators (US-UK)
12 000,355
3 decimals, comma for decimals and space for thousands separators (FR)
12,000.36
2 decimals, no separators specified (period for decimals and comma for thousands by default)
The last decimal digit is rounded by the PHP function.
12,000
No decimal nor separator specified (no decimals, comma for thousands by default)
PHP
In function.php