indigotree/wp-bootstrap-nav-walker

WordPress Nav Walkers to implement Bootstrap navbars.

1.1.4 2024-01-17 16:35 UTC

This package is auto-updated.

Last update: 2024-11-17 18:33:38 UTC


README

WordPress Nav Walkers to implement Bootstrap navbars.

Requirements

  • PHP 5.4+
  • WordPress 4.4+

Installation

Easy installation with Composer.

composer require indigotree/wp-bootstrap-nav-walker

Usage (Bootstrap 3)

Update wp_nav_menu() to use the IndigoTree\BootstrapNavWalker\Three\WalkerNavMenu walker. For example:

<?php

wp_nav_menu([
    'theme_location' => 'primary',
    'depth' => 2,
    'container' => 'div',
    'container_class' => 'collapse navbar-collapse',
    'container_id' => 'primary-navbar-collapse',
    'menu_class' => 'nav navbar-nav',
    'fallback_cb' => '__return_empty_string',
    'walker' => new \IndigoTree\BootstrapNavWalker\Three\WalkerNavMenu()
]);

Usage (Bootstrap 4)

Update wp_nav_menu() to use the IndigoTree\BootstrapNavWalker\Four\WalkerNavMenu walker. For example:

<?php

wp_nav_menu([
    'theme_location' => 'primary',
    'depth' => 2,
    'container' => 'div',
    'container_class' => 'collapse navbar-collapse',
    'container_id' => 'primary-navbar-collapse',
    'menu_class' => 'navbar-nav',
    'fallback_cb' => '__return_empty_string',
    'walker' => new \IndigoTree\BootstrapNavWalker\Four\WalkerNavMenu()
]);

License

The MIT License (MIT).