Reputation: 3653
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')) {
register_nav_menus(
array(
'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?
Thanks.
Upvotes: 0
Views: 2155
Reputation: 1
You can use array to store menu name and using loop we can iterate through array and use wp_nav_menu()
function to get menus.
<?php
$menus = array('menu_about','menu_services','menu_facilities');
?>
<nav class="footer-navigation">
<?php foreach ($menus as $value) { ?>
<ul class="footer-navigation-wrapper">
<?php
wp_nav_menu(array(
'menu' => $value,
'items_wrap' => '%3$s',
'container' => false,
'link_before' => '<div>',
'link_after' => '</div>',
'fallback_cb' => false,
));
}
?>
</ul>
</nav>
Upvotes: 0
Reputation: 3653
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.
Upvotes: 0