Looking to add custom menus in WordPress for your custom theme? All you may need is to register the menu in your WordPress theme’s functions.php file.
3 answers
1
Registering custom menus in WordPress
To register the custom menus in your WordPress theme, you need to add a function to register this in your theme’s functions.php file.
- Navigate to Appearance > Editor > Theme Functions from your WordPress Dashboard;
- Add in the code below to register three different menus (you can change this accordingly);
- Click Update File to save the changes.
function custom_menus() { register_nav_menus( array( 'primary' => 'Primary menu', 'secondary' => 'Secondary menu', 'tertiary' => 'Tertiary menu' ) ); } add_action( 'init', 'custom_menus' );
— Support WizardAnswer 1
0
Using custom menus in the front-end
You can use the custom menus you create in your WordPress theme by using the following code below to display wherever you need the menus shown.
wp_nav_menu( array( 'theme_location' => 'primary', 'container' => false, ) );
Note, you can read the WordPress documentation on wp_nav_menu(); to find out more on which arguments you can pass through the function’s array to better tailor the front-end results.
— Support WizardAnswer 2
0
Using custom menus in the back-end (WordPress Admin)
To use and adjust the registered menus you’ve created through your WordPress theme’s functions.php file, you can follow the steps below.
- Navigate to Appearance > Menus in your WordPress Dashboard;
- Create a new menu and give it any recognisable name;
- After creating the menu and dragging in the pages you require, tick the display location you’ve registered to show in that specific location;
- Click Save Menu to save the changes.
— Support WizardAnswer 3