Skip Navigation

[Resolved] Number Formatting in Number Field Type

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 1 year, 5 months ago.

Assisted by: Minesh.

Author
Posts
#2628009

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.

#2628039

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/

#2628481

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]