custom post types – Highlighting wp_nav_menu Ancestor Class w/o Children in Nav Structure? – WordPress Development Stack Exchange

add_filter(‘nav_menu_css_class’, ‘current_type_nav_class’, 10, 2 ); function current_type_nav_class($classes, $item) { $post_type = get_query_var(‘post_type’); if ($item->attr_title != ” && $item->attr_title == $post_type) { array_push($classes, ‘current-menu-item’); }; return $classes; } This snippet allows you to check if the current menu item has a … Continue reading