WP_REST_Menu_Items_Controller::get_nav_menu_item() WordPress Method

The WP_REST_Menu_Items_Controller::get_nav_menu_item() method is used to retrieve a single navigation menu item. The menu item is specified by its ID.

WP_REST_Menu_Items_Controller::get_nav_menu_item( int $id ) #

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


Parameters

$id

(int)(Required)Supplied ID.


Top ↑

Return

(object|WP_Error) Post object if ID is valid, WP_Error otherwise.


Top ↑

Source

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

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


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.