WP_REST_Templates_Controller::get_item( WP_REST_Request $request )

Returns the given template


Parameters Parameters

$request

(WP_REST_Request) (Required) The request instance.


Top ↑

Return Return

(WP_REST_Response|WP_Error)


Top ↑

Source 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 );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.