WP_REST_Navigation_Fallback_Controller::get_item( WP_REST_Request $request ): WP_REST_Response|WP_Error

In this article

Gets the most appropriate fallback Navigation Menu.

Parameters

$requestWP_REST_Requestrequired
Full details about the request.

Return

WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

Source

public function get_item( $request ) {
	$post = WP_Navigation_Fallback::get_fallback();

	if ( empty( $post ) ) {
		return rest_ensure_response( new WP_Error( 'no_fallback_menu', __( 'No fallback menu found.' ), array( 'status' => 404 ) ) );
	}

	$response = $this->prepare_item_for_response( $post, $request );

	return $response;
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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