Starting from visitor’s comment that asked about the wp_bootstrap_navwalker.php does not support with the latest jquery version, I will share new tutorial how to create a bootstrap menu on WordPress theme without navwalker library. For the last article please read how to create WordPress theme with bootstrap and underscores step by step. Okay, let’s begin the tutorial, hope fixes your problem
NOTE : After a few trials, this method resulted in a dropdown menu can’t work properly 🙁 . I suggest you keep using nav_walker_library pada tutorial Create WordPress Theme with Bootstrap And Underscores Step by Step.
I assume you have read my article about how to create a WordPress theme, if not please use this link. Because I am not going to discuss it in detail for making WordPress theme, but simply an alternative way to make navbar menu bootstrap on WordPress menu without using the wp_bootstrap_navwalker.php library.
Step by step transfers bootstrap menu in WordPress theme
Edit header.php and copy the navbar bootstrap menu code below
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152<!-- navbar --><div class="navbar-wrapper"><div class="navbar navbar-inverse navbar-fixed-top" role="navigation"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="sr-only">Toggle Navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title='<?php echo esc_attr( get_bloginfo( 'description', 'display' ) ); ?>' rel='home' ><img src="<?php bloginfo('stylesheet_directory'); ?>/assets/img/logosmall.png" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"></a></div><!-- navbar-header --><?php wp_nav_menu( array( 'theme_location' => 'primary','container' =>'nav','container_class' => 'navbar-collapse collapse','menu_class' => 'nav navbar-nav navbar-right') );?></div><!-- container --></div><!-- navbar --></div><!-- navbar-wrapper -->Register new menu at function.php and copy the following code below
1234// This theme uses wp_nav_menu() in one location.register_nav_menus( array('primary' => esc_html__( 'Primary', 'azoncastv2' ),) );Open footer.php and copy the following code below
12345<!-- BOOTSTRAP CORE JAVASCRIPT --><!-- jQuery (necessary for Bootstrap's JavaScript plugins) --><!-- Include all compiled plugins (below), or include individual files as needed --><script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>Create new WordPress menu and set theme location at “Primary”. Save the menu!.
Please see the results in your browser
For the complete Sourcecode please download at the following links
I am so waiting for your suggestions about this article, hopefully can be a new lesson for me. Please comment in the form below.So the tutorial how to easily transfers bootstrap navbar menu to wordpress theme, hope useful
Thank You, Sigit Prasetya for helping us by showing step by step tutorial with coding. This is very informative and important for the developers.
Hi, your code helped me greatly. However I also stumbled onto a fix for your problem.
I think you missed out a div.
Here is the amended code, my navbar has a working dropdown and responsive button which drops down now.
http://pastebin.com/AmdGcjGE
Let me know if this works, I don;t think I missed anything out.
I think the problem is we need wp_bootstrap_navwalker to create dropdown navbar 🙂
Hi Sigit Prasetya Nugroho,
Many thanks for your step by step guidance of coding. It’s really helpful to the developers.