0

How can I get this menu with wp_nav_menu()? This menu is created with Bootstrap.

<ul id="menu-main_menu" class="nav navbar-nav navbar-center">
    <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-5 current_page_item menu-item-8">
        <a href="#">Home</a>
    </li>
    <li  id="menu-item-25" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-25 dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About Us <span class="caret"></span></a>
            <ul class="dropdown-menu">
                <li>
                    <a href="#">Our Founders</a>
                </li>
                <li>
                    <a href="#">Our Vision</a>
                </li>
                <li>
                    <a href="#">Our Strategy</a>
                </li>
                <li>
                    <a href="#">How We Work</a>
                </li>
            </ul>
    </li>
    <li id="menu-item-26" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-26 dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects <span class="caret"></span></a>
            <ul class="dropdown-menu">
                <li>
                    <a href="#">Our Projects</a>
                </li>
                <li>
                    <a href="#">Past Projects</a>
                </li>
                <li>
                    <a href="#">Current Projects</a>
                </li>
            </ul>
    </li>
    <li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27">
        <a href="#">News &amp; Events</a>
    </li>
    <li id="menu-item-30" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-30">
        <a href="#">Contact</a>
    </li>
</ul>
0

This can achieve with a nav walker. I used this. I am stepping according to the mentioned.

  1. Put navwalker (wp-bootstrap-navwalker.php) in your theme root
  2. Call to the navwalker in functions.php file. require_once('wp-bootstrap-navwalker.php');
  3. Create your menu in Wordpress Backend (Appearance -> Menus)
  4. In your menu area, according to me in header.php
wp_nav_menu( array(
  'menu' => 'main_menu',
  'depth' => 2,
  'container' => false,
  'menu_class' => 'nav navbar-nav navbar-center',
  'walker' => new wp_bootstrap_navwalker())
);
`main_menu` is my menu name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.