afb/button/text

Filters the resolved button-label text, after the “Use the URL / Load from another field / Custom text” selection has been applied. Use this to tweak the rendered label without changing the underlying field value — for example, appending an icon character or normalizing capitalization.

Available on Button display format.

Parameters

apply_filters( 'afb/button/text', $text, $field, $attr );Code language: PHP (php)
  • $text (string) — The button label text about to be rendered.
  • $field (array) — The ACF field array.
  • $attr (array) — The block attributes array.

Modifiers

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

Example

// Always append an arrow to button labels.
add_filter( 'afb/button/text', function( $text ) {
    return $text . ' →';
} );Code language: PHP (php)