wordpress menu create

first create a php file theme-setup.php in inc folder ihen in functions.php file include it
by
require_once(get_template_directory().'/inc/theme-setup.php');
in theme-setup.php file register menu by
<?php

register_nav_menus(array(
'header_menus' => 'Header Menus',
'footer_menus' => 'Footer Menus'

));

 ?>

then where menu location we chack this is the container or ul that which is repeated
<div class="navbar-collapse collapse align-left">
                        <?php
                            wp_nav_menu(array(
                                'theme_location'    => 'header_menus',
                                'container'             => 'div' if exist,
                                'container_class' => 'div class '
                                'menu'              => 'ul',
                                'menu_class'        =>  'nav navbar-nav',
                               'menu_id'              => 'ul id'
                                'depth'             => '3',
                                'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
                                'walker'            =>  new WP_Bootstrap_Navwalker()


                            ))

                         ?>
                        
                    </div>

if drop-down menu have then we GitHub file nav walker WordPress in google  and we find this link
https://github.com/wp-bootstrap/wp-bootstrap-navwalker
 and download class-wp-bootstrap-navwalker.php file inset in inc folder and require in functions.php file

after we add wp_nav_menu
                               'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
                                'walker'            =>  new WP_Bootstrap_Navwalker()

Comments