acf_field_post_object::format_valuepublicACF 3.6

This filter is appied to the $value after it is loaded from the db and before it is returned to the template

Method of the class: acf_field_post_object{}

No Hooks.

Returns

Mixed. $value

Usage

$acf_field_post_object = new acf_field_post_object();
$acf_field_post_object->format_value( $value, $post_id, $field );
$value(mixed) (required)
The value found in the database.
$post_id(mixed) (required)
The post_id from which the value was loaded.
$field(array) (required)
The field array holding all the field options.

Changelog

Since 3.6 Introduced.

acf_field_post_object::format_value() code ACF 6.8.8

public function format_value( $value, $post_id, $field ) {
	$value = acf_get_numeric( $value );

	// bail early if no value
	if ( empty( $value ) ) {
		return false;
	}

	// load posts if needed
	if ( $field['return_format'] == 'object' ) {
		$value = $this->get_posts( $value, $field );
	}

	// convert back from array if neccessary
	if ( ! $field['multiple'] && is_array( $value ) ) {
		$value = current( $value );
	}

	// return value
	return $value;
}