/ Published in: PHP
Add current class to single posts in Wordpres wp_nav_menu by adding a filter
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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) { }; return $classes; }