I have a field on the admin side where a user enters a number for a price. If a user enters 1000000 I’d like to be able to display on the front-end $1,000,000.
Any ideas on how to accomplish this?
Edit
More details, the post is a custom post type ‘property’.
To add the meta fields on the back-end I’m using Meta Box Script, http://www.deluxeblogtips.com/2011/03/meta-box-script-update-v30.html
The code to display the numbers on the front-end I use
$meta = get_post_meta(get_the_ID(), 'rw_propPrice', true); echo $meta;
To format number, you can use the function
number_format_i18n
(it’s not documented now, but you can see its source here). Its work is format the number based on the language. You might want to look atnumber_format
(PHP built_in function, and is used bynumber_format_i18n
) to have more control to decimal point and thousand separator.In your case, this code will help you:
Just a guess (you really need to be more specific in your Q – what screen, how did you add it, metabox/settings section/bla???)…