wp-bootstrap / wp-bootstrap-navwalker

A custom WordPress nav walker class to fully implement the Twitter Bootstrap 4.0+ navigation style (v3-branch available for Bootstrap 3) in a custom theme using the WordPress built in menu manager.
https://wp-bootstrap.github.io/wp-bootstrap-navwalker/
GNU General Public License v3.0
3.37k stars 1.94k forks source link

How to easily customize the style of dropdown submenus? #460

Open stefanobartoletti opened 4 years ago

stefanobartoletti commented 4 years ago

Is there a way to easily add classes to elements of the dropdown submenus, in order to correctly style them and their child elements?

Right now, they always get the default styles, which is a white background whit blue highlight.

Is it possible to somehow pass list of classes to add to the relevant elements when the WP_Bootstrap_Navwalker() is instantiated? This would make it easier to always keep the relevant styling, because by directly modifying wp-bootstrap-navwalker.php all customizations would be lost when updating to new released versions.

As an example, with a simple dropdown with just one sublevel, I think that the elements that should be able to receive list of classes should be: ul.dropdown-menu > li.nav-item > a.dropdown-item.

I don't know what could be the best way to accomplish this, but like I said, a suggestion could be to have variables containing list of classes passed down when instantiating the class, in a similar way of the Wordpress core function wp_nav_menu()

IanDelMar commented 3 years ago

Related to #458