Search code examples
phpwordpressadvanced-custom-fields

Return ACF Number Fields Formatted with Spaces instead of commas


I have this code that helps me to add the comma between thousands but I need just a space instead of commas, how can I do this? I'm new to ACF and PHP as well, so just can't figure out how to do this, help me, please :( Should be something like this 20 000 instead of this 20,000

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

Solution

  • Just in case someone needs this

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