acf_field_relationship::format_value_for_jsonld
Formats the field value for JSON-LD output.
Method of the class: acf_field_relationship{}
No Hooks.
Returns
mixed.
Usage
$acf_field_relationship = new acf_field_relationship(); $acf_field_relationship->format_value_for_jsonld( $value, $post_id, $field );
- $value(mixed) (required)
- The value of the field.
- $post_id(int|string) (required)
- The ID of the post.
- $field(array) (required)
- The field array.
Changelog
| Since 6.8.0 | Introduced. |
acf_field_relationship::format_value_for_jsonld() acf field relationship::format value for jsonld code ACF 6.8.8
public function format_value_for_jsonld( $value, $post_id, $field ) {
$value = acf_format_numerics( $value );
if ( ! $value ) {
return $value;
}
if ( is_array( $value ) ) {
return array_map(
function ( $post_id ) {
return get_permalink( $post_id );
},
$value
);
}
return get_permalink( $value );
}