WP_REST_Post_Types_Controller::prepare_links()protectedWP 6.1.0

Prepares links for the request.

Method of the class: WP_REST_Post_Types_Controller{}

No Hooks.

Return

Array. Links for the given post type.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $post_type );
$post_type(WP_Post_Type) (required)
The post type.

Changelog

Since 6.1.0 Introduced.

WP_REST_Post_Types_Controller::prepare_links() code WP 6.5.2

protected function prepare_links( $post_type ) {
	return array(
		'collection'              => array(
			'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
		),
		'https://api.w.org/items' => array(
			'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ),
		),
	);
}