acf_field_taxonomy::format_value
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_taxonomy{}
No Hooks.
Returns
$value. (mixed) the modified value
Usage
$acf_field_taxonomy = new acf_field_taxonomy(); $acf_field_taxonomy->format_value( $value, $post_id, $field );
- $value(required)
- .
- $post_id(required)
- .
- $field(required)
- .
Changelog
| Since 3.6 | Introduced. |
acf_field_taxonomy::format_value() acf field taxonomy::format value code ACF 6.8.8
function format_value( $value, $post_id, $field ) {
// bail early if no value
if ( empty( $value ) ) {
return false;
}
// force value to array
$value = acf_get_array( $value );
// load posts if needed
if ( $field['return_format'] == 'object' ) {
// get posts
$value = $this->get_terms( $value, $field['taxonomy'] );
}
// convert back from array if neccessary
if ( $field['field_type'] == 'select' || $field['field_type'] == 'radio' ) {
$value = array_shift( $value );
}
// return
return $value;
}