You might find a really cool theme and then think to yourself it might be nice if it had an extra navigation menu in the footer with important or frequently used links to increase the usability of your WordPress site.
It only takes a little bit of coding to get your menus into place, and ready for you to style to match your theme.
In order to create new navigation menus you will need to edit some of your files. Its always a good idea to backup your site before editing any files. You will be able to restore your site like nothing ever happened.
Constructing a Child Theme
To create new menus with code, you’ll need to make changes to files that will be lost when you update your theme. Creating a child theme takes care of this issue. It always WordPress best practice to use child theme when editing files. If you dont have a child them you can refer to a previous post on how to create a child theme.
Creating New Menus
To add a selectable menu location option in your admin dashboard under Appearance > Menus you need to do what’s called “register a menu.” All it takes is adding a snippet of code to your functions.php file. Locate your functions.php file amd scroll to the bottom of the file. If you’d like to add only one menu, add the following code on a new line:
New Menu is the name that will appear in your admin dashboard’s menu page to make it understandable for this example. The new-menu name is what WordPress will understand to execute your code properly.
If you would like to add more then one menu to your site add this code on a new line instead.
All you have to do now is add the new menu to your website.
Adding Menu Locations to Your Theme
Now you’ll have to decide where you want to put your new menu. Maybe your adding a secondary navigation to the header or you want that extra navigation to go in the footer. You can even edit a template file and put it on a page. I want to add mine to the footer of my site so I’ll be editing the footer.php file.
You can place your new menu where ever you’d like. Here’s the minimum amount of code you need to add to any of these locations:
Now your new menu will show up on your site where you placed it but your probably going to want to style it with css. Now in order to do that youll need to create a new menu class and add that to your theme. You can build on the above code and add a class name by adding this to your file.
Just like before, replace new-menu with the name you chose. In this example, I named the class I created new_menu_class. You can change this, but just be sure to update this code to reflect the adjustment.