last day (15 days later) » 

18:00
0
Q: current-menu-item class not working properly

Muhammad BilalI 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...

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.
@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/…
I am in this problem for few days but not able to find out solution for this.
Are you working with taxonomies, pages? Or what are you referring to, when your speaking about terms?
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.
You're just getting the first id, because the code in your other question is breaking after the first occurrence.
Are those hierarchical taxonomies?
18:02
Is there any way to get current id?
Yes these are hierarchical taxonomies.
Thank you for your time and help. It is much appreciated.
18:13
So you're mixing the taxonomies in your menu?
Because I think having the same term name in different taxonomies shouldn't add the class.
So you're using the same term of the same taxonomy on multiple instances?
But i have same term from same taxonomy with same url. But in my case these terms should bring different posts depending on its parent terms.
Yes you are right
I have the feeling you be doing it wrong. I would probably do it like this

-taxonomy
---parent1
------childA
------childX
---parent2
------childB
------childX
---parent3
------childC
------childX

You see, different parents can have the same child term name, here childX, without it being the same term, they have different ids, so they wouldn't get all highlighted.
Or the class current-menu-item added.
Anyhow, I got to go for now, good luck!
But i have different structure and my client requirements are strange. I can share a link for my site if you want to see?

last day (15 days later) »