1

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?

7
  • I'm over simplifying a little bit, but WordPress is applying 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. Commented Nov 7, 2017 at 16:44
  • @Nicolai Thank you so much for your time and help. I just want to get current menu id and if you want more detail then you can read this from here wordpress.stackexchange.com/questions/284986/…
    – wpdd
    Commented Nov 7, 2017 at 17:19
  • I am in this problem for few days but not able to find out solution for this.
    – wpdd
    Commented Nov 7, 2017 at 17:19
  • Are you working with taxonomies, pages? Or what are you referring to, when your speaking about terms? Commented Nov 7, 2017 at 17:49
  • I have four custom taxonomies and all these are assigned with lot of terms. I am using few of these terms in multiple places and i have three level menu. I have AND condition in my tax_query among menu item and its parent menus. I am getting menu id correctly with that code but when there are multiple occurrence of this term it always return id of first occurrence and it is because of current-menu-item class.
    – wpdd
    Commented Nov 7, 2017 at 17:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.