acf/format_value

Overview

This filter is applied to the $value after it is loaded from the db and before it is returned to the template via functions such as get_field().

Changelog

  • Renamed from acf/format_value_for_api in v5.0.0

Parameters

Name Type Description
$value mixed the value which was loaded from the database
$post_id mixed the post ID from which the value was loaded
$field array An array containing all the field settings for the field which was used to upload the attachment

Usage

There are 2 possible ways to hook into this filter.

  1. acf/format_value – filter for every field
  2. acf/format_value/type={$field_type} – filter for a specific field based on it’s type

functions.php

<?php
 
function my_acf_format_value( $value, $post_id, $field ) {
	
	// run do_shortcode on all textarea values
	$value = do_shortcode($value);
	
	
	// return
	return $value;
}

add_filter('acf/format_value/type=textarea', 'my_acf_format_value', 10, 3);
 
?>

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.