title: wordpress bootstrap navigation navbar auto collapse, not in open state
body: <p><a href="https://i.stack.imgur.com/hFXai.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hFXai.gif" alt="enter image description here"></a>I am developing a WordPress theme and for navbar using a navwalker code,
  the problem is when I click on the menu button in mobile it's open and closed in a millisecond. It's working in localhost properly but not in the server.</p>
  
  <p>Wordpress: 5.2
  navwalker: custom WordPress nav walker class for Bootstrap 4 
  Bootstrap: 4.3.1
  URL of site: <a href="https://www.androidinterview.com/" rel="nofollow noreferrer">https://www.androidinterview.com/</a></p>
  
  <pre><code>&lt;header id="masthead" class="site-header has-header"&gt;
      &lt;nav id="menu" class="navbar navbar-expand-lg  navbar-light"&gt;
          &lt;div class="site-branding navbar-brand"&gt;
              &lt;?php
              the_custom_logo();
              if ( is_front_page() &amp;&amp; is_home() ) :
                  ?&gt;
                  &lt;p class="site-title"&gt;&lt;a href="&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;" rel="home"&gt;&lt;?php bloginfo( 'name' ); ?&gt;&lt;/a&gt;&lt;/p&gt;
                  &lt;?php
              else :
                  ?&gt;
                  &lt;p class="site-title"&gt;&lt;a href="&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;" rel="home"&gt;&lt;?php bloginfo( 'name' ); ?&gt;&lt;/a&gt;&lt;/p&gt;
                  &lt;?php
              endif;
              $ehsdev_description = get_bloginfo( 'description', 'display' );
              if ( $ehsdev_description || is_customize_preview() ) :
                  ?&gt;
                  &lt;p class="site-description"&gt;&lt;?php echo $ehsdev_description; /* WPCS: xss ok. */ ?&gt;&lt;/p&gt;
              &lt;?php endif; ?&gt;
          &lt;/div&gt;&lt;!-- .site-branding --&gt;
  
  
          &lt;button class="navbar-toggler p-0" type="button" data-toggle="collapse" data-target="#bs4navbar" aria-controls="bs4navbar" aria-expanded="false" aria-label="Toggle navigation"&gt;
              &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
           &lt;/button&gt;
  
          &lt;?php
          wp_nav_menu([
              'menu'              =&gt; 'primary',
              'theme_location'    =&gt; 'primary',
              'container'         =&gt; 'div',
              'container_id'      =&gt; 'bs4navbar',
              'container_class'   =&gt; 'collapse navbar-collapse',
              'menu_id'           =&gt; 'false',
              'menu_class'        =&gt; 'navbar-nav ml-auto',
              'depth'             =&gt; 2,
              'fallback_cb'       =&gt; 'bs4navwalker::fallback',
              'walker'            =&gt; new bs4Navwalker()
          ]);
          ?&gt;
      &lt;/nav&gt;
  
      &lt;/header&gt;&lt;!-- #masthead --&gt;
  </code></pre>
  
  <p>function.php</p>
  
  <pre><code>require get_template_directory() . '/inc/bootstrap-wp-navwalker.php';
  
  register_nav_menus( array(
              'primary' =&gt; esc_html__( 'Primary', 'ehsdev' ),
          ) );
  
  </code></pre>