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 can I inject before last closing tag of container? #389

Closed codyburleson closed 5 years ago

codyburleson commented 6 years ago

In order to get a search widget in the top-right of the header navbar, it needs to go before the closing tag of the container generated by the navwalker. Is it possible in some way now to use a param to inject with get_search_form(true) or get_search_form(false), foe example?

pattonwebz commented 5 years ago

For this one you should be able to just not output a container via wp_nav_menu() by passing something like false in the args for container like so:

wp_nav_menu( array(
            'theme_location'    => 'primary',
            'depth'             => 2,
            'container'         => 'false',
            'menu_class'        => 'nav navbar-nav',
            'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
            'walker'            => new WP_Bootstrap_Navwalker(),
        ) );

And wrapping it yourself in whatever container you want allowing you to add anything before or after it :)