carbonmadex
Member
Posted 1 year ago #
My menu is like this:
Blog (page)
- Blog 1 (page which displays posts under blog category)
- Blog 2 (page which displays posts under blog category with a diff. template)
...
When I go to "Blog 1", "Blog" in the menu is highlighted properly. However when I open a single post from the blog category the highlight doesn't work anymore. Because wp_nav_menu doesn't generate neccessary classes for it at this point. I think to be able to achieve this I need to add a jQuery code or something. Can anyone help me please?
Note: I cannot use special post classes like giving specific slugs or IDs because this will be used in a template.
Because wp_nav_menu doesn't generate neccessary classes for it at this point.
Yes it does. Try styling on .current_page_parent a or .current_page_ancestor a.
carbonmadex
Member
Posted 1 year ago #
Yes it does. Try styling on .current_page_parent a or .current_page_ancestor a.
Unfortunately it doesn't. When I look at the page from view source the only classes generated are:
<li id="menu-item-352" class="menu-item menu-item-type-post_type menu-item-352"><a href="http://fadelicious.iki-bir.com/wp/blog">Blog</a>
carbonmadex
Member
Posted 1 year ago #
CookiesForDevo
Member
Posted 10 months ago #
This is something you can work around, but it's a bit messy.
If you're using body_class() in your theme, then the body tag should have a class of something like single-blog-1.
You can use CSS then to target the nav ID (for example):
body.single-blog-1 li#menu-item-352 {}
What's the link to your site? I might be able to help with the actual Classes and IDs then.