Calling different navigation menus for different pages
-
Hi there,
I’m trying to call different navigation menus for different landing pages but I’m stuck.. Here’s what I’ve done up to now:
1. Registered secondary navigation in functions.php :
register_nav_menu('game_nav', THEME_NAME . ' Game Navigation');
2. Created a dedicated page template for the secondary landing page as page-game.php
So far, so good. Both the secondary menu & page template show up at the backend of the site. All I need to do now – as far as my understanding goes – is to call the different menus in an else/if statement in header.php which I tried to do like below, but all goes wrong…My site now just shows up with a logo but no nav menu or home page load. Sorry, site is not live yet so link is not helpful..
<?php if (is_page_template('page.php')){ wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' => 'main_nav', 'menu_id' => 'nav')); } elseif (is_page_template('game-page.php')){wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' => 'game_nav', 'menu_id' => 'nav')); } else { echo theme_generator('menu'); } ?>
The original was:
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' =>'main_nav', 'menu_id' => 'nav')); ?>
Any help would be much appreciated!
Thanks
- The topic ‘Calling different navigation menus for different pages’ is closed to new replies.