(Moderators note: Was originally titled "wp_nav_menu Ancestor class without children in navigation structure")
I have a
wp_nav_menu in my header which had three pages in it. When I am on one of those pages, the
li containing that page in the menu gets the class
.current_page_item. These three pages have templates, and these templates contain custom queries to get all posts of a certain content type. In effect, the perceived "children" of this top level page are not actually children, they're just of a content type I've associated with that top level page using a template.
I'd like the top level menu items to get a
'current-ancestor' class when the user is browsing a single page of a specific post type, again, associated with that page only in a custom query in the template file.
Hope that makes sense - if not, let me know where I lost you! Very much appreciate any help.
--Edited for specifics: For example, I have a static page called Workshops that is using a template. Its slug is workshops. The template has a custom get_posts function and loop within it, which pulls and displays all posts of a custom content type called workshops. If I click on one of these workshops' title, I'm taken to the full content of that piece of content. The permalink structure of the custom post type is set to workshops/postname, so as the user sees it, these pieces of content are children of the Workshops page, when in reality they're all of one content type but unrelated to the page. It's that gap that I need to effectively close in the menu, highlighting the 'Workshops' menu item when browsing content of type 'workshop'.
Again, hope that makes sense, I think I said 'workshop' upwards of 20 times in one paragraph!