Skip Navigation

[Resolved] Need to format a number field (999,999,999), coming from ACF

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to format the number coming from ACF field
Solution:
To format the number in your desired format you need to write custom shortcode where you should pass your ACF field value to it and the shortcode return you the formatted number.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/need-to-format-a-number-field-999999999-coming-from-acf/#post-625516

Relevant Documentation:
http://php.net/number-format

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#625484

Hi,

I’m helping a client with her site by implementing a view to display data coming from ACF fields.

We need to format a number field to show using the default number format ex: 999,999,999

Can you point me to any code or examples on how I might achieve this?

#625516

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to format the number in your desired format you need to write custom shortcode where you should pass your ACF field value to it and the shortcode return you the formatted number.

For example:

function format_my_number($atts) {
    $num = $atts["value"];
     
    return number_format($num, 0, '.', ',');
}
add_shortcode("custom-number-format", "format_my_number");

And you can use it as:

[custom-number-format  value="PASS-YOUR-ACF-FIELD-VALUE"] 

You can adjust the number format as required. More info - hidden link