WP_REST_Templates_Controller::prepare_links()protectedWP 5.8.0

Prepares links for the request.

{} It's a method of the class: WP_REST_Templates_Controller{}

No Hooks.

Return

Array. Links for the given post.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $id );
$id(int) (required)
ID.

Changelog

Since 5.8.0 Introduced.

Code of WP_REST_Templates_Controller::prepare_links() WP 6.0

protected function prepare_links( $id ) {
	$base = sprintf( '%s/%s', $this->namespace, $this->rest_base );

	$links = array(
		'self'       => array(
			'href' => rest_url( trailingslashit( $base ) . $id ),
		),
		'collection' => array(
			'href' => rest_url( $base ),
		),
		'about'      => array(
			'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
		),
	);

	return $links;
}