Hello all you helpful people 🙂
I am using a self modified version of the 2012 theme and I would like to be able to display a different main navigation menu based on the category I am viewing.
Firstly is there a plugin for such a thing as a GUI would be easier for me to get to grips with
If not I’m guessing it will be PHP in the header.php file? I already have if statements for custom headers per category so I can add the additional code for switching menus in here.
Any help is great 🙂
My existing menu code is:
<nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
Main menu is called ‘Talkative’
Custom menu is called ‘Pirtek’
I cannot see in the existing code what would be changed unless I have to add additional function calls to wp_nav_menu for example
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' 'menu' => 'Talkative') ); ?>
Try the following
Haven’t tried it, but this should work.
For details check is_category() and wp_nav_menu()