add .current-post-ancestor to nav-menu
-
Dear all, I’m working on a project which has a custom post type “products” and a custom taxonomy “class”, the structure like this :
Home <- index.php Home/Products/ <- a page with custom page template, use
get_terms('class')
to list all value in Class Home/Products/Class <- taxonomy-class.php , list products in this class Home/Products/Class/Product-Post <- single-products.php , the product detailAnd I setup a nag-menu like this :
-Home -Products --Crab ( class - custom taxonomy ) --Shrimp ( class - custom taxonomy ) -about -contact
1. When I’m in Products page, WP will add a
.current-menu-item
to Products tab.
2. When I’m in Crab page, WP will add a.current-menu-item
to Crab and add.current-menu-parent
to Products.Here is what I want :
When I’m in Snow-Crab (belongs to Crab) , I want to add.current-post-parent
to Crab , and.current-post-ancestor
to Products on nev-menu , so I can style with CSS to highlight it.Is there any way to do it ?
It can be done like normal category and post relationship , just use post type archive page to Products page in nev-menu , but the problem is I use the way in this topic to make permalink in right structure , which makes my post type archive permalink became
products/%class%
, can’t be interpreted correctly in nav-menu and even can do it , WP will still not add.current-post-parent
to Crab tab (sub-menu to Praducts) in nav-menu.Anyone has idea ?
Thanks you.
- The topic ‘add .current-post-ancestor to nav-menu’ is closed to new replies.