![register and display menu wordpress register and display menu wordpress](http://blog.obd2shop.co.uk/wp-content/uploads/2022/08/autel-ultra-lite-register-5.jpg)
Now your menu is ready, you can add items to your menu which is on the left-hand side. Then click on the “Edit Menus” option, you will find a link as create a new menu, click on to that link, and create a name for your menu. In your WordPress admin dashboard, you will find Appearance > Menus option. After adding those above codes you can see your site like thisĬreating a new menu using WordPress admin dashboardġ. So nothing to get much stressed about displaying the menus. Note: You can give the above snippet anywhere as you wish, wherever you give it works. In case if you wish to add the menus to the footer as well, then enter the following lines of code, in footer.php as well: ‘secondary’)) ?> The syntax for displaying the navigation menu isįor example, if we want to display the menu in the header, then we have to override the header.php file by adding the following code: ‘primary’)) ?> To display the navigation menu, we use wp_nav_menu() function in WordPress. Display navigation menuīased on your preference you can display the navigation menu wherever you want.
#Register and display menu wordpress code
If you add this code in a functions.php file, then the menus will be added under Appearance > Menus > Theme Locations. If you wish to add multiple menus, then add the following lines of code, instead of the previous code: _( 'Primary Header Menu' ),Īdd_action( 'init', 'register_my_menus' ) Init is the action hook here, it is used to run your function when initialized. You can enter the following lines of code, on the functions.php file: Register_nav_menus(array($location1=>$description, $location2=>$description) – Create multiple menus Register_nav_menu($location, $description) – Create single Menu
![register and display menu wordpress register and display menu wordpress](https://i2.wp.com/images.uv-light.org/l-m/samsung-galaxy-note-10-plus-5g.jpg)
![register and display menu wordpress register and display menu wordpress](https://ramyashwebacademy.files.wordpress.com/2018/01/89dab-screenshot_1.png)
You have to register this in the functions.php file which is in your themes folder. Initially, to display the menu option in your WordPress dashboard, you have to register the navigation menu using register_nav_menu() function. 3 Creating a new menu using WordPress admin dashboard.2.1 After adding those above codes you can see your site like this.