Ability to use "dropup" class for menu items with submenus
I've tried to use the "theme_location" argument to change "dropdown" class by "dropup" but I get the following error when "theme_location" is specified:
Notice: Trying to get property of non-object in /path/to/wp_bootstrap_navwalker.php on line 67
It would be great for footer menus.
Hey @kcmr,
Dropups are a tricky thing. The truth is they are both supported and not supported by the navwalker. There are some specific use cases where it works pretty well, and others it just doesn't look right and requires additional CSS.
Method One
Dropups are natively supported if you are using the navbar-fixed-bottom menu class. This is the only method I have found to make a dropup work with the menu tick pointing in the right direction.
To define this you would do it outside of the menu/walker declaration.
Example One
<div class="navbar navbar-inverse navbar-fixed-bottom">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">Project name</a>
<?php
wp_nav_menu( array(
'menu' => 'footer_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav',
'walker' => new wp_bootstrap_navwalker())
);
?>
</div>
</div>
</div>
Method Two
You can turn any dropdown in a nav into a dropup menu by simply adding dropup to the menu_class variable when adding the menu/walker to your theme but without css modifications the menu tick points up from the top of the dropup and not down towards the menu as it should. So it will need some additional hacks to make it work.
Example Two
<?php
wp_nav_menu( array(
'menu' => 'top_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav dropup',
'fallback_cb' => 'wp_page_menu',
//Process nav menu using our custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
There is a GitHub issue referencing a .bottom-up CSS class you can add but it seems that it is no longer in the Bootstrap less code. Because additional CSS is needed for other cases outside that which is already included with bootstrap I wont be able to add it to the class at this time.
Hope it help.