PHP code example of fiskhandlarn / bootstrap-5-wordpress-navbar-walker
1. Go to this page and download the library: Download fiskhandlarn/bootstrap-5-wordpress-navbar-walker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fiskhandlarn / bootstrap-5-wordpress-navbar-walker example snippets
register_nav_menu('main-menu', 'Main menu');
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
wp_nav_menu([
'theme_location' => 'navigation',
'container' => false,
'menu_class' => '',
'fallback_cb' => '__return_false',
'items_wrap' => '<ul id="%1$s" class="navbar-nav me-auto mb-2 mb-lg-0 %2$s">%3$s</ul>',
'depth' => 2,
'walker' => new Fiskhandlarn\Bootstrap5WordpressNavbarWalker(),
]);