Home Forums General Issues Number Field formatting (placing commas)


Number Field formatting (placing commas)

  • Hi there guys,

    I find it kind of strange that they Number field type does now allow for any formatting of commas or decimals in its options.

    I’m trying to display commas in the number type field, like so:
    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!

  • Update:
    Above code worked like so:

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

    I can now see the correct comma separators for new entries that I place in the number field.
    Any suggestion as to how I can ‘correct’ previous entries as well?
    Otherwise, I have to manually adjust more than 100 different entries/listings!!

    THanks for any suggestions.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.