WP_REST_Templates_Controller::get_item( WP_REST_Request $request )

Returns the given template

Parameters

$request

(WP_REST_Request) (Required) The request instance.

Return

(WP_REST_Response|WP_Error)

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php

public function get_item( $request ) {
		$template = get_block_template( $request['id'], $this->post_type );

		if ( ! $template ) {
			return new WP_Error( 'rest_template_not_found', __( 'No templates exist with that id.' ), array( 'status' => 404 ) );
		}

		return $this->prepare_item_for_response( $template, $request );
	}

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_templates_controller/get_item