WP_REST_Menu_Items_Controller::get_menu_id() – Gets the id of the menu that the given menu item belongs to.

You appear to be a bot. Output may be restricted

Description

Gets the id of the menu that the given menu item belongs to.

Usage

$int = WP_REST_Menu_Items_Controller::get_menu_id( $menu_item_id );

Parameters

$menu_item_id
( int ) required – Menu item id.

Returns

int

Source

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


Lines:

1 to 10 of 10
  protected function get_menu_id( $menu_item_id ) {
    $menu_ids = wp_get_post_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
    $menu_id  = 0;
    if ( $menu_ids && ! is_wp_error( $menu_ids ) ) {
      $menu_id = array_shift( $menu_ids );
    }

    return $menu_id;
  }
 

 View on GitHub View on Trac