Add menu classes to nav.php

How can i get the CSS classes entered in the Wordpress menu item field CSS classes showing in the menu via nav.php?

thanks!

This is working in Sage 8.0.1. (and old Roots versions). What happens when you enter the class? Do you get an error? Just to be clear: the class you enter here gets added to the menu <li> element not the <a> element.

Also confirmed that this is working as expected

ok - I can work with that… but it only shows one class from the CSS Classes field? ie its missing the class page-scroll from the contact li.

this is because the class page-scroll is getting removed by Sage Walker in nav.php. the problem is that your class has the word “page” in it and Sage cleans up the default WordPress Walker menu and removes a bunch of classes that get added by default by targeting words “menu” and “page” (https://github.com/roots/sage/blob/master/lib/nav.php#L91). you could removed this line and the class will show up but the menus will not be that clean as they are now (you’ll get all the WordPress default menu classes back) or you could use a different class than page-scroll. i presume you need this for some custom java script easing or linking to page sections. so probably you can use what ever class you want for that. maybe there is even an option to make the pattern that the preg_replace function uses to be more specific and not to remove your class but honestly i don’t know how to pull that of :smile: . hope this helps.

ah i see — that’s cleared it all up then! Thanks slobich.