Changing Primary Nav on selected pages
-
I’m currently using woo commerce and i have 4 items in the top nav menu
About Us – Portfolio – Blog – ShopThis is my primary-nav and is fine to be displayed this way for all the pages except ‘Shop’. Ive created another menu within wordpress ‘shop-menu’ which is only to be displayed on the shop page but i cant seem to get it to work correctly.
The secondary nav appears on the blog page when is shouldnt and when you click on any of the options from the secondary nav it goes back to primary nav.
for example… on the shop page it has the secondary nav that has:
My Account – Cart – Track your order – checkoutwhen i click on cart for example it should still display that same nav but it jumps back to displaying primary nav
hope you can help
Ive added this code to the functions.php
if ( function_exists( 'wp_nav_menu') ) { add_theme_support( 'nav-menus' ); register_nav_menus( array( 'primary-menu' => __( 'Primary Menu', 'woothemes' ) ) ); register_nav_menus( array( 'top-menu' => __( 'Top Menu', 'woothemes' ) ) ); register_nav_menus( array( 'shop-menu' => __( 'Shop Menu', 'woothemes' ) ) ); }
and this within header.php
<nav id="navigation" class="col-full" role="navigation"> <?php $exclude_pages = ('shop'); if (has_nav_menu( 'shop-menu' ) && !is_page($exclude_page_id)) { wp_nav_menu( array( 'depth' => 6, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'main-nav', 'menu_class' => 'nav fr', 'theme_location' => 'shop-menu' ) ); } elseif(has_nav_menu( 'primary-menu' ) && is_page($exclude_page_id)) { wp_nav_menu( array( 'depth' => 6, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'main-nav', 'menu_class' => 'nav fr', 'theme_location' => 'primary-menu' ) ); } else { ?> <ul id="main-nav" class="nav fl"> <?php if ( is_page() ) $highlight = 'page_item'; else $highlight = 'page_item current_page_item'; ?> <li class="<?php echo $highlight; ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php _e( 'Home', 'woothemes' ); ?></a></li> <?php wp_list_pages( 'sort_column=menu_order&depth=6&title_li=&exclude=' ); ?> </ul><!-- /#nav --> <?php } ?> </nav><!-- /#navigation -->
- The topic ‘Changing Primary Nav on selected pages’ is closed to new replies.