I have a custom post type and a custom taxonomy. Each custom post type is assigned to exactly one term. I added a menu entry for each term in my custom taxonomy. Behind each of menu entries is a overview page with all the custom posts assigned to this term. If you click on one of the customs posts a details page opens. But if you are on a details page the corresponding menu entry for the taxonomy term is no longer marked as active. What am I doing wrong?
Share
Ok, I found the following solution for my problem:
But there is still one problem left. I also want to add the class current-menu-ancestor to the parent element. I have the id of the parent element via
$item->menu_item_parentbut no idea how I can use this id to change the classes of the corresponding menu entry at this point?