acf_field_taxonomy::get_rest_links
Method of the class: acf_field_taxonomy{}
No Hooks.
Returns
Array.
Usage
$acf_field_taxonomy = new acf_field_taxonomy(); $acf_field_taxonomy->get_rest_links( $value, $post_id, $field );
- $value(mixed) (required)
- The raw (unformatted) field value.
- $post_id(int|string) (required)
- .
- $field(array) (required)
- .
Notes
- See: [acf_field::get_rest_links()](/plugin/acf/function/acf_field::get_rest_links)
acf_field_taxonomy::get_rest_links() acf field taxonomy::get rest links code ACF 6.0.4
public function get_rest_links( $value, $post_id, array $field ) {
$links = array();
if ( empty( $value ) ) {
return $links;
}
foreach ( (array) $value as $object_id ) {
$term = get_term( $object_id );
if ( ! $term instanceof WP_Term ) {
continue;
}
$rest_base = acf_get_object_type_rest_base( get_taxonomy( $term->taxonomy ) );
if ( ! $rest_base ) {
continue;
}
$links[] = array(
'rel' => 'acf:term',
'href' => rest_url( sprintf( '/wp/v2/%s/%s', $rest_base, $object_id ) ),
'embeddable' => true,
'taxonomy' => $term->taxonomy,
);
}
return $links;
}