Hi,
I need to display a "Number" field with thousand space separator, two decimal, and currency symbol.
Needed display: 1 000 000,25 €
Regards.
Jean
Hello,
There isn't such kind of built-in feature, it needs custom codes, for example, you can try these:
1) Create a custom shortcode with a custom PHP function:
https://developer.wordpress.org/reference/functions/add_shortcode/
2) In this PHP function:
a) get your custom number field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
b) format as what you want:
hidden link
Hi there,
Many thanks for your help.
I'm very sorry, but I'm not a PHP developer at all and I'm not able to achieve with my poor programing skills. So, I need a more detailed step by step guideline, with a view to achieve.
Can you do that for me, or give me where to find it (tuto or video...)
Regards.
Jean
Here is a demo site:
Login URL:
hidden link
Detail steps:
1) Create a custom number field "test-n-f"
hidden link
2) Dashboard-> Toolset-> Settings-> Custom code
Add a new item, with below codes:
add_shortcode('currency_format', function($atts, $content){
$res = do_shortcode($content);
$res = number_format($res, 2, ',', ' ');
return $res;
});
3) Create a post, display above custom shortcode like this:
[currency_format][types field='test-n-f' output='raw'][/types][/currency_format]
It works fine in frontend:
hidden link
For your reference.
My issue is resolved. Thank you!