acf/format_value


目录

Description

Filters the field $value after being loaded by a template function such as get_field().

Changelog

Parameters

apply_filters( 'acf/format_value', $value, $post_id, $field );

Modifers

This filter provides modifiers to target specific fields. The following filter names are available:

Example

This example demonstrates how to modify a field’s value when loaded by a template function.

functions.php

<?php
function my_acf_format_value( $value, $post_id, $field ) {

    // Render shortcodes in all textarea values.
    return do_shortcode( $value );
}

// Apply to all fields.
// add_filter('acf/format_value', 'my_acf_format_value', 10, 3);

// Apply to textarea fields.
add_filter('acf/format_value/type=textarea', 'my_acf_format_value', 10, 3);

// Apply to fields named "hero_text".
// add_filter('acf/format_value/name=hero_text', 'my_acf_format_value', 10, 3);

// Apply to field with key "field_123abcf".
// add_filter('acf/format_value/key=field_123abcf', 'my_acf_format_value', 10, 3);

版本号 #1
由 壳壳虫 创建于 2026-08-29 15:44:03 UTC
由 壳壳虫 更新于 2026-08-29 15:44:03 UTC