afb/accordion/icon

Available on Accordion display format. Filters the SVG markup used as the open/close toggle icon for accordion sections. Returning a different SVG string replaces the default caret-down icon. Useful when matching a theme’s iconography, switching to a custom icon set, or — via the modifier variants — using a different icon for specific accordions.

Parameters

apply_filters( 'afb/accordion/icon', $svg, $field, $attr );Code language: PHP (php)
  • $svg (string) — The SVG markup rendered as the toggle icon.
  • $field (array) — The ACF field array.
  • $attr (array) — The block attributes array.

Modifiers

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

Example

// Replace the toggle icon with a custom SVG for one specific accordion.
add_filter( 'afb/accordion/icon/key=field_5f1a2b3c4d5e6', function() {
    return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="1em" height="1em">'
         . '<path d="M3 5l5 6 5-6H3z" />'
         . '</svg>';
} );Code language: PHP (php)