Forked from gerbenvandijk/Mark parent navigation active when on custom post type single page
Last active
March 29, 2018 05:48
-
-
Save mjawaids/d9f95795f1cdc71df79e0db1ba6444ae to your computer and use it in GitHub Desktop.
Mark (highlight) custom 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
Updated to fix a bug where $current_post_type->rewrite['slug']; was missing quotes in 'slug'. And returned class 'active' for Bootstrap/Underscore based themes.