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?
Leave a Reply
You must be logged in to post a comment.
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_parent
but no idea how I can use this id to change the classes of the corresponding menu entry at this point?So my solution works if you have a page title with the same name as the menu item
you would like to add the class
current-page-item
to.Ofcourse, you need jQuery installed to get this working.
edit: Make sure you put this underneath the loop on your archive-taxonomy page.
You can do it via jquery:
I’ve been struggling with this for some time. This is how I solved my problem.
You can use other methods to inject the css into the archive page of course.