WP_REST_Menu_Items_Controller::get_nav_menu_item()protectedWP 5.9.0

Get the nav menu item, if the ID is valid.

{} It's a method of the class: WP_REST_Menu_Items_Controller{}

No Hooks.

Return

Object|WP_Error. Post object if ID is valid, WP_Error otherwise.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_nav_menu_item( $id );
$id(int) (required)
Supplied ID.

Changelog

Since 5.9.0 Introduced.

Code of WP_REST_Menu_Items_Controller::get_nav_menu_item() WP 6.0

protected function get_nav_menu_item( $id ) {
	$post = $this->get_post( $id );
	if ( is_wp_error( $post ) ) {
		return $post;
	}

	return wp_setup_nav_menu_item( $post );
}