Gets the id of the menu that the given menu item belongs to.
Parameters
$menu_item_id
intrequired- Menu item id.
Source
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;
}
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.