acf_field_page_link::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_page_link{}
No Hooks.
Returns
$value. (mixed) the modified value
Usage
$acf_field_page_link = new acf_field_page_link(); $acf_field_page_link->format_value( $value, $post_id, $field );
- $value(required)
- .
- $post_id(required)
- .
- $field(required)
- .
Changelog
| Since 3.6 | Introduced. |
acf_field_page_link::format_value() acf field page link::format value code ACF 6.0.4
function format_value( $value, $post_id, $field ) {
// ACF4 null
if ( $value === 'null' ) {
return false;
}
// bail early if no value
if ( empty( $value ) ) {
return $value;
}
// get posts
$value = $this->get_posts( $value, $field );
// set choices
foreach ( array_keys( $value ) as $i ) {
// vars
$post = acf_extract_var( $value, $i );
// convert $post to permalink
if ( is_object( $post ) ) {
$post = get_permalink( $post );
}
// append back to $value
$value[ $i ] = $post;
}
// convert back from array if neccessary
if ( ! $field['multiple'] ) {
$value = array_shift( $value );
}
// return value
return $value;
}