acf_get_field_rest_links()
Get the REST API field links for a given field. The links are appended to the REST response under the _links property and provide API resource links to related objects. If a link is marked as 'embeddable', WordPress can load the resource in the main request under the _embedded property when the request contains the _embed URL parameter.
Hooks from the function
Returns
Array.
Usage
acf_get_field_rest_links( $post_id, $field );
- $post_id(string|int) (required)
- .
- $field(array) (required)
- .
Notes
- See: [acf_field::get_rest_links()](/plugin/acf/function/acf_field::get_rest_links)
- See: https://developer.wordpress.org/rest-api/using-the-rest-api/linking-and-embedding/
acf_get_field_rest_links() acf get field rest links code ACF 6.0.4
function acf_get_field_rest_links( $post_id, array $field ) {
$value = acf_get_value( $post_id, $field );
$type = acf_get_field_type( $field['type'] );
$links = $type->get_rest_links( $value, $post_id, $field );
/**
* Filter the REST API links for a given field.
*
* @param array $links
* @param string|int $post_id
* @param array $field
* @param mixed $value
*/
return (array) apply_filters( 'acf/rest/get_field_links', $links, $post_id, $field, $value );
}