garrettweinberg / sage-bootstrap5-navwalker
Bootstrap 5 Navbar component navwalker for Sage 10 based themes
Installs: 24 574
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 3
Open Issues: 1
Requires
- php: >=5.3.2
README
Forked from MWDelaney/sage-bootstrap4-navwalker
Sets up a Bootstrap 5 Navwalker for Sage 10 based themes.
To install, run the following in your Sage 10 based theme directory:
composer require "garrettweinberg/sage-bootstrap5-navwalker"
Include the navwalker in your wp_nav_menu
function:
As a Controller method (Recommended)
In your Controller, probably app.php
public function with() { return [ 'primaryNavigation' => $this->primaryNavigation(), ]; } /** * Primary Nav Menu arguments * @return array */ public function primaryNavigation() { $args = array( 'theme_location' => 'primary_navigation', 'container' => '', 'container_class' => '', 'menu_class' => 'navbar-nav', 'depth' => 4, 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'walker' => new \App\wp_bootstrap5_navwalker() ); return $args; }
In your Blade file, probably header.blade.php
@if (has_nav_menu('primary_navigation')) {!! wp_nav_menu($primaryNavigation) !!} @endif
Without Controller
If you're not setting up your template data with Controller, you'll need to fully reference the \App\wp_bootstrap5_navwalker()
.
In your Blade file, probably header.blade.php
@if (has_nav_menu('primary_navigation')) {!! wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'navbar-nav', 'walker' => new \App\wp_bootstrap5_navwalker()]) !!} @endif