How to Display Navigation Menus of our Custom Theme in WordPress?
In blog Part-7, we have seen how to register Navigation Menus of our Custom Theme. We have to create pages to make menus.
Step 1:- Go to Dashboard->Pages->Add New Page. Name the first menu as Home page, second About page, third Menu page, forth Specials page, fifth Events page, sixth Gellary page, seventh Chefs page, eighth Contact page, ninth Book a Table page. Click Publish.
Step 2:-Go to Appearance->Menus–>Pages Check menu items boxes which are created and Click Add to Menu.
Menu Structure
Step 3:– Rearrange menus name according to your needs by dragging its.
Step 4:– To Display Location Checkbox of Primary Menu and Click Save Menu.
Step 5:- Go to index.php file of customtheme folder and delete the given nav-menu to see your created new nav-menu.
Step 6:– To display nav-menu, use pre-defined wp_nav_menu( array $args = array() ) method in WordPress. To more details of this method, visit https://developer.wordpress.org/reference/functions/wp_nav_menu/.
wp_nav_menu(array(
'menu' =>'primary-menu', //id of Primary Menu
'container' => '',
'items_wrap' =>'<ul class="nav navbar-nav navbar-right headerMenu">%3$s</ul>'
));
Step 7:- Put this wp_nav_menu( array $args = array() ) method in nav-menu section
Step 8:- Refresh the custom theme site.
Thanks
- How to Login with Token in Laravel PHP Framework? - October 30, 2021
- How to merge two or multiple tables to each other in the Laravel PHP Framework? (Part-4) - October 29, 2021
- How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? Part-2 - October 29, 2021