PHP code example of jorgelsaud / bootstrap-nav-walker

1. Go to this page and download the library: Download jorgelsaud/bootstrap-nav-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/ */

    

jorgelsaud / bootstrap-nav-walker example snippets


// Register Custom Navigation Walker

add_filter('get_custom_logo','change_logo_class');


function change_logo_class($html)
{
    $html = str_replace('class="custom-logo"', 'img-fluid', $html);
    $html = str_replace('class="custom-logo-link"', 'navbar-brand', $html);
    return $html;
}

register_nav_menus( array(
    'primary' => __( 'Primary Menu', 'THEMENAME' ),
) );

// Register Custom Navigation Walker

 
            wp_nav_menu( array(
                'menu'              => 'primary',
                'theme_location'    => 'primary',
                'depth'             => 2,
                'container'         => 'div',
                'container_class'   => 'collapse navbar-collapse',
        'container_id'      => 'bs-example-navbar-collapse-1',
                'menu_class'        => 'nav navbar-nav',
                'fallback_cb'       => '\jorgelsaud\WordpressTools\NavWalker::fallback',
                'walker'            => new \jorgelsaud\WordpressTools\NavWalker())
            );
        

register_nav_menus( array(
    'primary' => __( 'Primary Menu', 'THEMENAME' ),
) );

<nav class="navbar navbar-light bg-faded">
  <button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar2">
    &#9776;
  </button>
  <div class="collapse navbar-toggleable-xs" id="exCollapsingNavbar2">
    <a class="navbar-brand" href=" echo home_url();