Overview

This action works on version 4.0.0 and above. If using version 3, please use acf_load_value

Description

This hook allows you to modify the value of a field right after it is loaded from the database.

Requirements

  • ACF version 4.0.0 or above

Parameters

  • $value – the value of the field as found in the database
  • $post_id - the post id which the value was loaded from
  • $field - the field object (actually an array, not object)

Usage

There are 4 ways to hook into acf_load_value.

  1. acf/load_value - filter for every value load
  2. acf/load_value/type={$field_type} – filter for a value load based on it’s field type
  3. acf/load_value/name={$field_name} – filter for a specific value load based on it’s field name
  4. acf/load_value/key={$field_key} – filter for a specific value load based on it’s field key

This code is used in the functions.php file

<?php
 
function my_acf_load_value( $value, $post_id, $field )
{
    // run the_content filter on all textarea values
    $value = apply_filters('the_content',$value); 
 
    return $value;
}
 
// acf/load_value - filter for every value load
add_filter('acf/load_value', 'my_acf_load_value', 10, 3);
 
// acf/load_value/type={$field_type} - filter for a value load based on it's field type
add_filter('acf/load_value/type=select', 'my_acf_load_value', 10, 3);
 
// acf/load_value/name={$field_name} - filter for a specific value load based on it's field name
add_filter('acf/load_value/name=my_select', 'my_acf_load_value', 10, 3);
 
// acf/load_value/key={$field_key} - filter for a specific field based on it's name
add_filter('acf/load_value/key=field_508a263b40457', 'my_acf_load_value', 10, 3);
 
?>