How to add multiple menus in WordPress theme?


I am developing a new WordPress theme, and I need two menus, the main menu, and the footer menu. This is what I have in functions.php:

if ( function_exists('register_nav_menus')) {
            'main' => 'Main Menu',
            'footermenu' => 'Footer Menu'

And, I am calling two menus, one in header.php and other in footer.php:

<?php $main_menu = array('menu' => 'main', 'container' => 'nav' ); wp_nav_menu( $main_menu ); ?>

<?php $footer_menu = array('menu' => 'footermenu', 'container' => 'nav' ); wp_nav_menu( $footer_menu ); ?>

I am also assigning both menus a different menu in WordPress Menus Manager, but in both menus, only the menu I assign to the first one is shown. I don’t know why. Can anybody help me solve this?



Okay, I’ve solved this. Instead of menu, I had to use theme_location, because this represents the menu chosen from the menu admin panel.

Answered By – Amar Syla

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published