HOW TO REGISTER NAV MENU IN WORDPRESS?

The easiest way to add the nav manu in the dashboard is by using “register_nav_menus()” function and hook in the functions.php
The syntax is as follow:

function menu_name(){
“header” => “primary Menu”,
“footer” => “Footer Menu”
}

add_action(“init”,”menu_name”);

// in the above header and footer are the two menus that I am going to embade in my project. You can give other name and you can create as many menus as you want

After this process you have to hook the function by using add_action. You must use ‘init’ and ‘menu_name’ is the the of the function

SHOW MENU IN FRONTEND


if(has_nav_menu(“header){

wp_nav_menu(array(

‘menu_class’ => ‘ ‘,
‘menu_id’ => ”,

‘container_class’ => ‘ ‘,
‘container_id’ => ‘ ‘,

‘before’ => ”,
‘after’ => ”,

‘link_before’ => ”,
‘link_after’ => ”
));
}
?>

here ‘menu_class’ and ‘menu_id’ is class and class and id for ul respectively. ‘container_class’ and ‘container_id’ is the class and id for the div respectively.