afb/value

Filters the raw field value loaded from ACF before any per-display-format formatting is applied. Use this to normalize, sanitize, replace, or completely override the value the block will render.

Parameters

apply_filters( 'afb/value', $value, $field, $attr );Code language: PHP (php)
  • $value (mixed) — The raw field value loaded from ACF.
  • $field (array) — The ACF field array.
  • $attr (array) — The block attributes array.

Modifiers

TagApplies to
afb/valueAll ACF fields.
afb/value/type={$type}All fields of a specific field type.
afb/value/name={$name}All fields with a specific field name.
afb/value/key={$key}A single field, matched by field key.

Example

// Trim whitespace from every text field's value before rendering.
add_filter( 'afb/value/type=text', function( $value ) {
    return is_string( $value ) ? trim( $value ) : $value;
} );Code language: PHP (php)