acf/schema/format_value/name={field_name}

Last updated Mar 31, 2026

Overview

Filter formatted values for a specific field name.

Description

This filter is a field name specific version of acf/schema/format_value. It allows you to modify formatted values only for fields with a specific name.

The dynamic portion of the hook name, {field_name}, refers to the ACF field name.

Changelog

  • Added in version 6.8.0

Parameters

apply_filters( 'acf/schema/format_value/name={field_name}', $formatted_value, $value, $field_object );
  • $formatted_value (mixed) The value after default formatting
  • $value (mixed) The original raw field value
  • $field_object (array) The field object with settings

Return

(mixed) The modified formatted value.

Example

This example formats a price field with currency.

/**
 * Format price field with currency symbol.
 *
 * @param mixed $formatted_value The formatted value.
 * @param mixed $value           The raw value.
 * @param array $field_object    The field object.
 * @return mixed Modified value.
 */
function my_acf_schema_format_price( $formatted_value, $value, $field_object ) {
    // Ensure 2 decimal places
    return number_format( (float) $formatted_value, 2, '.', '' );
}
add_filter( 'acf/schema/format_value/name=price', 'my_acf_schema_format_price', 10, 3 );

This example converts duration minutes to ISO 8601 format.

/**
 * Convert duration field to ISO 8601.
 *
 * @param mixed $formatted_value The formatted value.
 * @param mixed $value           The raw value (minutes).
 * @param array $field_object    The field object.
 * @return string ISO 8601 duration.
 */
function my_acf_schema_format_duration( $formatted_value, $value, $field_object ) {
    $minutes = (int) $value;
    $hours   = floor( $minutes / 60 );
    $mins    = $minutes % 60;

    if ( $hours > 0 ) {
        return sprintf( 'PT%dH%dM', $hours, $mins );
    }
    return sprintf( 'PT%dM', $mins );
}
add_filter( 'acf/schema/format_value/name=cooking_time', 'my_acf_schema_format_duration', 10, 3 );
add_filter( 'acf/schema/format_value/name=prep_time', 'my_acf_schema_format_duration', 10, 3 );
Supercharge Your Website With Premium Features Using ACF PRO

Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone

Related