...
Tutorials, Wordpress

How to use wp_nav_menu() in wordpress?

01 April 2019

Display Menus # Once you’ve registered your menus, you need to use wp_nav_menu() in wordpress to tell your theme where to display them. For example, add the following code to your header.php file to display the header-menu that was registered above.

Given a theme_location parameter, the function displays the menu assigned to that location.

For Example:
<?php
    $defaults = array(
    'theme_location' => 'main-menu', // assign a menu name
    'menu_class' => 'nav navbar-nav navbar-right', // class name                                  
    'container' => false,
   );
   echo wp_nav_menu($defaults);
 ?>   
output here:

wp_nav_menu

Leave a Comments