I create field type which number type. If i input 1000000 then how to make it automatically have separate dot in front end? Like 1.000.000 so it is easier to read.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
What if you try to use the following shortcode, Please add the following code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
function func_format_number ( $atts ) {
extract( shortcode_atts( array(
'number' => '0'), $atts) );
return $price = number_format($price, 2, ',', '.');
}
add_shortcode('format_number ', 'func_format_number ');
Where:
- Adjust the code as per your required format.
And you can call the shortcode as:
[format_number number=[wpv-post-field name="your-field-slug"]][/format_number ]
Where:
- Replace "your-field-slug" with your original field slug.
- Add the shortcode name "format_number " (without quotes) at:
=> Toolset => Settings => Front-end Content tab => Third-party shortcode arguments
More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/how-to-create-a-custom-shortcode/
Got work code from your answer in another question. Thanks Minesh!
--
add_shortcode('number-format', 'number_format_shortcode');
function number_format_shortcode($atts, $content = "") {
$number = floatval(wpv_do_shortcode($content));
return number_format($number, 0,' .', '. ');
}
--
[number-format][types field='boligannonse-pris' format='FIELD_VALUE'][/types][/number-format]