PHP code example of garrettweinberg / sage-bootstrap5-navwalker

1. Go to this page and download the library: Download garrettweinberg/sage-bootstrap5-navwalker 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/ */

    

garrettweinberg / sage-bootstrap5-navwalker example snippets


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;
    }

@if (has_nav_menu('primary_navigation'))
  {!! wp_nav_menu($primaryNavigation) !!}
@endif

@if (has_nav_menu('primary_navigation'))
  {!! wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'navbar-nav', 'walker' => new \App\wp_bootstrap5_navwalker()]) !!}
@endif