How to build Bootstrap’s Auto Dropdown menu in WordPress

Using wp-bootstrap-navwalker class
Download from this link Download

Installation

Place wp-bootstrap-navwalker.php in your WordPress theme folder /wp-content/your-theme/

Open your WordPress themes functions.php file /wp-content/your-theme/functions.php and add the following code:
// Register New Custom Navigation Walker
require_once(‘wp-bootstrap-navwalker.php’);

Usage

Update your wp_nav_menu() function in header.php to use the new walker by adding a “walker” item to the wp_nav_menu array.

        < ? php
            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'       => 'WP_Bootstrap_Navwalker::fallback',
                'walker'            => new WP_Bootstrap_Navwalker())
            );
        ?>

Add Style for Automatic Dropdown Come

ul.nav li.dropdown:hover ul.dropdown-menu{ display: block; }