当有多个菜单时,在菜单上丢失页面ID

I created a menu which I output on a page... each li of the menu had the page ID as an id allowing me to target specific li's.

When I added the 2nd and 3rd location for the same menu, all the id's disappeared so a lot of my styling messed up due to it no longer outputting the id's. How can I get these back when there's multiple menus?

I'm registering 3 menu locations using the following:

// Register our themes menu locations
function register_menus() {
    register_nav_menu('primary-menu', __('Primary Menu'));
    register_nav_menu('mobile', __('Mobile Menu'));
    register_nav_menu('products', __('Products Menu'));        
    register_nav_menu('footer-menu', __('Footer Menu'));
}
add_action('init', 'register_menus');

Assigning the same menu to the 3 locations:

enter image description here

Then outputting in my template with the following:

<?php if ( has_nav_menu( 'primary-menu' ) ) {
wp_nav_menu( array(
  'container'=>'div',
  'menu_class'=>'1',
  'theme_location' => 'primary-menu',
  'walker' => new CSS_Menu_Maker_Walker(),
  'items_wrap' => '<ul class="primary-menu-1">%3$s</li></ul>'
));
} ?>


<?php if ( has_nav_menu( 'mobile' ) ) {
  wp_nav_menu( array(
    'container'=>'div',
    'menu_class'=>'2',
    'theme_location' => 'mobile',
    'walker' => new CSS_Menu_Maker_Walker(),
    'items_wrap' => '<ul class="primary-menu-2">%3$s</li></ul>'
  ));
} ?>


<?php if ( has_nav_menu( 'products' ) ) {
  wp_nav_menu( array(
    'container'=>'div',
    'menu_class'=>'3',
    'theme_location' => 'products',
    'walker' => new CSS_Menu_Maker_Walker(),
    'items_wrap' => '<ul class="primary-menu-3">%3$s</li></ul>'
  ));
} ?>

Adding 'menu'=>'my-class-name', to each menu instance brings them back.

Add for all the instance you have add 'menu'=>'name', Hope it helps

please add the Parameters menu, menu_class, menu_id.

and use this link for the further https://developer.wordpress.org/reference/functions/wp_nav_menu/