W3cubDocs

/WordPress

WP_REST_Post_Search_Handler::prepare_item_links( int $id )

Prepares links for the search result of a given ID.

Description

Parameters

$id

(int) (Required) Item ID.

Return

(array) Links for the given item.

Source

File: wp-includes/rest-api/search/class-wp-rest-post-search-handler.php

public function prepare_item_links( $id ) {
		$post = get_post( $id );

		$links = array();

		$item_route = $this->detect_rest_item_route( $post );
		if ( ! empty( $item_route ) ) {
			$links['self'] = array(
				'href'       => rest_url( $item_route ),
				'embeddable' => true,
			);
		}

		$links['about'] = array(
			'href' => rest_url( 'wp/v2/types/' . $post->post_type ),
		);

		return $links;
	}

Changelog

Version Description
5.0.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_post_search_handler/prepare_item_links