So with the new TT3 theme, doesn't look like we can use nav_menu_css_class
filter anymore to add custom classes to menu items (<li>
) or nav_menu_link_attributes
for the anchors (<a>
) like we did before:
add_filter('nav_menu_css_class', function ($classes){
$classes[] = 'custom-nav-item';
return $classes;
}, 10 , 2);
add_filter( 'nav_menu_link_attributes', function($atts) {
$atts['class'] = 'custom-nav-link';
return $atts;
}, 100, 1 );
likely because menus are now created via the new Customize->Editor and don't fire the hook which was a formerly initiated by a hardcoded wp_nav_menu
in theme template files.
Has anyone figured out how to add custom classes to menu items in twentytwentythree?