WP_REST_Templates_Controller::get_template_fallback()publicWP 6.1.0

Returns the fallback template for the given slug.

Method of the class: WP_REST_Templates_Controller{}

No Hooks.

Return

WP_REST_Response|WP_Error.

Usage

$WP_REST_Templates_Controller = new WP_REST_Templates_Controller();
$WP_REST_Templates_Controller->get_template_fallback( $request );
$request(WP_REST_Request) (required)
The request instance.

Changelog

Since 6.1.0 Introduced.

WP_REST_Templates_Controller::get_template_fallback() code WP 6.1.1

public function get_template_fallback( $request ) {
	$hierarchy         = get_template_hierarchy( $request['slug'], $request['is_custom'], $request['template_prefix'] );
	$fallback_template = resolve_block_template( $request['slug'], $hierarchy, '' );
	$response          = $this->prepare_item_for_response( $fallback_template, $request );
	return rest_ensure_response( $response );
}