WP_REST_Term_Search_Handler::prepare_item_links( int $id ): array[]

In this article

Prepares links for the search result of a given ID.

Parameters

$idintrequired
Item ID.

Return

array[] Array of link arrays for the given item.

Source

public function prepare_item_links( $id ) {
	$term = get_term( $id );

	$links = array();

	$item_route = rest_get_route_for_term( $term );
	if ( $item_route ) {
		$links['self'] = array(
			'href'       => rest_url( $item_route ),
			'embeddable' => true,
		);
	}

	$links['about'] = array(
		'href' => rest_url( sprintf( 'wp/v2/taxonomies/%s', $term->taxonomy ) ),
	);

	return $links;
}

Changelog

VersionDescription
5.6.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.