Filters the final HTML string produced by any ACF field block, just before it’s returned to the renderer. Use this to wrap the output, append/prepend markup, run sanitizers, or replace the rendered HTML entirely.
Parameters
apply_filters( 'afb/output', $output, $field, $attr );Code language: PHP (php)
$output(string) — The rendered block HTML.$field(array) — The ACF field array.$attr(array) — The block attributes array.
Modifiers
| Tag | Applies to |
|---|---|
afb/output | All ACF fields. |
afb/output/type={$type} | All fields of a specific field type. |
afb/output/name={$name} | All fields with a specific field name. |
afb/output/key={$key} | A single field, matched by field key. |
Example
// Wrap the rendered output of a specific field in a card container.
add_filter( 'afb/output/key=field_5f1a2b3c4d5e6', function( $output ) {
return '<div class="card">' . $output . '</div>';
} );Code language: PHP (php)