0

I have used bootstrap nav walker but it works good with just 1 and 2 level , 3 level is not supported correctly.

I found one here http://www.dangtrinh.com/2015/05/multilevel-drop-down-menu-in-wordpress.html

but it is not that good .

How can I make navigation like one in blazok theme on themeforest.

3
  • Can you show the code you've tried and what you mean by "it is not that good"? With walkers I suggest you start out coding your HTML exactly as you want it to appear when rendered and troubleshoot any CSS and JS in that hard-coded copy. Next, you use a walker to slowly tweak WP's output until it matches your hard-coded HTML. It can be a process but you need to complete at least part of that process yourself. It's a good learning experience. :)
    – WebElaine
    Jun 6, 2017 at 14:10
  • Basically what I'm saying is - please provide a little code, and break your task into smaller steps. Folks here are better able to help with each small step where you get stuck. Most questions that ask for a full-blown solution go unanswered.
    – WebElaine
    Jun 6, 2017 at 14:11
  • I used navwlker class .....and it didn't work for 3 depth menu....then i tried this modification in code. dangtrinh.com/2015/05/… but this one is so vague means not user friendly at all. Jun 12, 2017 at 10:31

2 Answers 2

1

Download Bootstrap nav walker file.Call this file to your functions.php. Then Put this code to dynamic your nav menu:

 <?php
                        $args = array(
                            'theme_location'    => 'primary',
                            'menu'              => 'Main',
                            'container'         => 'false',
                            'container_class'   => '',
                            'container_id'      => '',
                            'menu_class'        => 'nav navbar-nav navbar-right',
                            'menu_id'           => '',
                            'echo'              => true,
                            'fallback_cb'       => 'wp_page_menu',
                            'before'            => '',
                            'after'             => '',
                            'link_before'       => '',
                            'link_after'        => '',
                            'items_wrap'        => '<ul id="%1$s" class="%2$s">%3$s</ul>',
                            'depth'             => 5,
                            'walker'            => new my_custom_walker_nav_menu()
                        );

                        wp_nav_menu ($args);
                        ?>

You can choose the value to the 'depth' key how many depth you need

1
  • drive file link is not working
    – İsmail
    Aug 8, 2021 at 20:23
0

I myself have wrote a class that can achieve this result. In any case, you need to write a Walker class (more precisely your class should extend Walker_Nav_Menu) and override the methods you need to change. Finally, include it in functions.php, inside a check for existing Walker_Nav_Menu. In code:

if (class_exists('Walker_Nav_Menu')) {
    class Walker_Custom_Bootstrap_Nav_Menu extends Walker_Nav_Menu {
        //Override Walker Methods
    }
}

Check more at the code reference, or study the file /wp-includes/class-walker-nav-menu.php which is very well commented.

I hope i'll be helpful for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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