Skip Navigation

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

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 6 años, 8 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Etiquetado: ,

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Minesh hace 6 años, 8 meses.

Asistido por: Minesh.

Autor
Mensajes
#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

Idiomas: Inglés (English )

Zona horaria: 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 - enlace oculto