Support

Account

Home Forums General Issues Formatting number fields using format_value Reply To: Formatting number fields using format_value

  • @hube2

    Hi there John,
    Could you help me? I’m trying to display commas in number type field, like so:
    120,000
    I tried some combinations of code I found in different threads, but nothing worked really!

    I have a particular field I want to format the numbers for, (listing_price).
    I also tried:

    add_filter('acf/format_value/number=listing_price', 'fix_number', 20, 3);
    function fix_number($value, $post_id, $field) {
      $value = number_format($value);
      return $value;
    	}

    but nothing happened.
    What do the numbers 20 and 3 mean above?
    I thought I’d need to replace them with my case for example 20000 (as currently displayed), to 20,000 as I want them displayed.
    In any case, code doesn’t work.

    Can you suggest something?

    Thank you for any help!