WP_REST_Term_Search_Handler::prepare_item_links()
Prepares links for the search result of a given ID.
Method of the class: WP_REST_Term_Search_Handler{}
No Hooks.
Return
Array[]
. Array of link arrays for the given item.
Usage
$WP_REST_Term_Search_Handler = new WP_REST_Term_Search_Handler(); $WP_REST_Term_Search_Handler->prepare_item_links( $id );
- $id(int) (required)
- Item ID.
Changelog
Since 5.6.0 | Introduced. |
WP_REST_Term_Search_Handler::prepare_item_links() WP REST Term Search Handler::prepare item links code WP 6.7.2
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; }