Support

Account

Home Forums General Issues Insert Commas into ACF number field Reply To: Insert Commas into ACF number field

  • hello guys,

    this was a helpful post, but it doesnt quite solve my issue. I have two fields that I would like to add commas. This might be a silly questions, but I am an extreme novice when it comes to PHP.

    I would like to add commas to “price” and the other is “square_footage”.

    The issue I am coming across is when I put both fields “price” & “square_footage”, I get an error, but if I only enter one, it works fine. What am I missing here?

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