acf_load_value

Overview

This action works on version 3.5.8.2 and below. If using version 4, 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 3.5.3 or above

Parameters

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

Usage

There are 4 ways to hook into acf_load_value.

  1. acf_load_value – filter for every value load
  2. acf_load_value-{$field_type} – filter for a value load based on it’s field type
  3. acf_load_value-{$field_name} – filter for a specific value load based on it’s field name
  4. acf_load_value-{$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, $field, $post_id )
{
    // run the_content filter on all textarea values
    $value = apply_filters('the_content',$value); 

    return $value;
}

// acf_load_value-{$field_type} - filter for a value load based on it's field type
add_filter('acf_load_value-textarea', 'my_acf_load_value');

?>