Categories: wordpress

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.

jaminrai

Recent Posts

Skype Closes Its Doors After 20 Years: A Look Back and the Apps That Faded with It

After 20 years of transforming global communication, Skype has officially ceased operations. Microsoft, which purchased…

2 months ago

The Duck and the Tortoise: A Tale of Patience and Teamwork

In a serene forest by the edge of a sparkling lake, there lived a cheerful…

3 months ago

10 Smart Strategies for a Secure and Enjoyable Retirement

Retiring comfortably is a goal many aspire to achieve, and with the right strategies, it’s…

3 months ago

Troubleshooting a Slow Computer

Is your computer running frustratingly slow? Don't worry; you're not alone in facing this common…

3 months ago

The Clever Fox and the Greedy Crow

Once, in a sunny forest, Fox and Crow were friends. One day, Crow found a…

3 months ago