I am using same term multiple time in my menu and when one term is active all occurrence of this term are assigned with current-menu-item
class.
Actually I am getting menu id when that specific term is assigned with current-menu-item
class.
But I always get id of its first occurrence. So how I can remove this class from other instances of this term so I can get a correct menu id?
current-menu-item
to all menu items with identical objects that are connected to the page you are viewing. Which definitely makes sense in a way, because generally you want to identify the element you are viewing, not the menu item you clicked. So I hate to break it to you, but I'm pretty sure it is indeed working properly and as intended. Otherwise I would advice you to add detailed information.