Bootstrap Templates Bundle

Thursday, January 1, 2015

How to Convert Bootstrap Menu to WordPress Menu

1. Register Menu from your functions.php file


     // This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'jhilik' ),
) );

2. Add This below code to your functions.php file 

/*--------------------------------------------
17.  Register custom navigation walker
----------------------------------------------*/
require_once('inc/wp_bootstrap_navwalker.php');


3. Put the wp_bootstrap_navwalker.php  file to your  inc folder (or any place) of your theme.
You can get the wp_bootstrap_navwalker.php  from here

4. Replace the header.php code

<ul class="nav navbar-nav">
                        <li class="active"><a href="index.html">Home</a></li>
                        <li><a href="about-us.html">About Us</a></li>
                        <li><a href="services.html">Services</a></li>
                        <li><a href="portfolio.html">Portfolio</a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Pages <i class="fa fa-angle-down"></i></a>
                            <ul class="dropdown-menu">
                                <li><a href="blog-item.html">Blog Single</a></li>
                                <li><a href="pricing.html">Pricing</a></li>
                                <li><a href="404.html">404</a></li>
                                <li><a href="shortcodes.html">Shortcodes</a></li>
                            </ul>
                        </li>
                        <li><a href="blog.html">Blog</a></li> 
                        <li><a href="contact-us.html">Contact</a></li>                        
</ul>

by 


 <?php
            wp_nav_menu( array(
                'menu'              => 'primary',
                'theme_location'    => 'primary',
                'depth'             => 2,
                'container'         => 'div',
                'container_class'   => 'collapse navbar-collapse navbar-ex1-collapse',
                'menu_class'        => 'nav navbar-nav',
                'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
                'walker'            => new wp_bootstrap_navwalker())
            );
        ?>







4 comments:

  1. Great webpage brother I am gona inform this to all my friends and contacts. premium wordpress themes

    ReplyDelete
  2. I would love to go for free WordPress hosting, and inside many free WordPress hosting control panels, you have the option to submit a "Ticket" if something goes wrong, and get help to fix it.

    WP Poetry Themes

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete

Murphy - Home Maintenance & Repair Service HTML Template

Murphy is a handyman repair service Bootstrap HTML Template. It is ideal for either all-rounders or professional teams to introduce the...