Problem: I would like to add commas to my number custom field when I display the value on the frontend of my site.
Solution: There is not a built-in way to do this in Toolset but a custom shortcode that can help. Add this code to your child theme's functions.php file:
add_shortcode( 'ts_format_number', 'ts_format_number_func'); function ts_format_number_func( $atts, $content ) { $int = (int) do_shortcode($content); return number_format($int, 0); }
Then you can use it like this to format the number field value:
[ts_format_number][types field="price"][/types][/ts_format_number]
Relevant Documentation:
http://php.net/manual/en/function.number-format.php
https://codex.wordpress.org/Shortcode_API
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by koheiY 6 years, 2 months ago.
Assisted by: Christian Cox.