Forked from gerbenvandijk/Mark parent navigation active when on custom post type single page
Last active
May 14, 2020 07:28
-
-
Save markhowellsmead/5aeb12903281f196af9678dc1cf87e20 to your computer and use it in GitHub Desktop.
Mark (highlight) post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Mark,
just one more thing. Your code works very well thank you. It keeps menu items active even if I have Blog > posts selected. It however does not keep a menu item active if I set up a menu Blog Category > Post.
Ie: if I set up a blog category > the category is listed and then a post item is selected from this it tends not to work.
Are you aware of this ? do you have a work around by any chance ?
thanks again for your help.