Support,
I would like to add a comma to my custom field, mileage, so that a comma appears when needed.
Page with mileage field (see left side of page, 10750): hidden link
I was able to apply the comma to price, but not mileage.
Thanks,
Chuck
Dear Chuck,
Thanks for the details, there isn't such a built-in feature within Types plugin, as a workaround your can create a custom shortcode for it, for example, I did below modification in your website:
1) Add below codes into your theme/functions.php:
//Adding comma to values over 999
function format_money( $atts, $content ) {
$content = do_shortcode($content);
$content = number_format($content);
return $content;
}
add_shortcode('format_money', 'format_money');
2) Edit the content template, "Motorcycle Post Submissions Layout" use above shortcode [format_money] to wrap the "mileage" field shortcode like this:
[format_money][types field='mileage'][/types][/format_money]
Please test again, check if it is what you want.
Luo,
It's working on this page: hidden link
But I tried the code on the map and it's not working. I got a script error when I tried it: hidden link
I assumed I would use the same code/format in the map view as the content template, but it didn't work.
Thanks,
Chuck
For the new problem, I checked the URL you mentioned above:
hidden link
click the map marker, I see the price value is: $5,500
Is this problem resolved? If you still need assistance for it, please point out where and how can I see the problem, thanks
The map shows the correct format for price, but not mileage. Mileage should have a comma.
Thanks,
Chuck
I added below codes into your theme/functions.php:
function display_number_func($output) {
return number_format($output, 0);
}
add_filter("wpcf_fields_slug_mileage_value_display", "display_number_func");
It will add comma into the "mileage" field automatically, please test again, check if it is fixed. thanks