askdesign
11/11/2015 - 9:07 PM

Create 1 extra menu in Genesis

https://wpsites.net/web-design/adding-additional-nav-menus-in-genesis/

Use this for GB Dog Training site. Needs a secondary menu for services page.

//* Original instructions
//* One. Register the menu(s) using the init action hook NOT after_theme_setup

//* Two. Hook the menu into a theme hook location ( You could replace the 2nd 
//* step with the template code which displays the menu however this is not best 
//* practice when modifying Genesis and reserved for parent theme development)

//* Simply change the genesis_after_header hook to the correct hook location you want to display your menu.

//* Three. You can also change the container class (nav-menu) to match the existing Genesis nav menu class or you 
//* would need to add a lot of CSS if you use a unique class.

// STEP 1
function register_additional_genesis_menus() {
register_nav_menu( 'third-menu' ,
__( 'Third Navigation Menu' ));
}
add_action( 'init', 'register_additional_genesis_menus' );

// STEP 2
add_action( 'genesis_after_header', 'add_third_nav' ); 
function add_third_nav() {

wp_nav_menu( array( 
'theme_location' => 'third-menu', 
'container_class' => 'genesis-nav-menu' ) );
}
// Add services navigation menu - ASK Design
// STEP 1
function register_services_genesis_menus() {
	register_nav_menu( 'services-menu' ,
	__( 'Services Navigation Menu' ));
	}
	add_action( 'init', 'register_services_genesis_menus' );
	 
// STEP 2
add_action( 'genesis_before_content', 'add_services_nav' ); 
	function add_services_nav() {

// modified with div class and echo below	in STEP 3
	wp_nav_menu( array( 
	'theme_location' => 'services-menu', 
	'container_class' => 'genesis-nav-menu' ) );
	}

// end of third nav menu custom code - ASK Design 

// STEP 3
// next step is to modify stylesheet for <ul id="menu-services" class="menu"> like so:
  
echo'

<div class="nav-services">';
wp_nav_menu( array( 
'theme_location' => 'services-menu', 
'container_class' => 'genesis-nav-menu' ) );
echo'</div>

';
// STEP 4
// Try this code to conditionally display services nav only on services page
// Will have to modify for gbdog

function add_services_nav() {
    if ( is_page( '9' ) )  {
        echo'<div class="nav-services">';
        wp_nav_menu( array( 
        'theme_location' => 'services-menu', 
        'container_class' => 'genesis-nav-menu' ) );
        echo'</div>';
    }
}

// STEP 4 - alternative
// Try this code to conditionally display services nav only on certain pages
// Will have to modify for gbdog

function add_third_nav_genesis() {
    if( is_page( array( 6, 7, 9 ) ) ) {
        echo'<div class="nav-services">';
        wp_nav_menu( array( 
        'theme_location' => 'third-menu', 
        'container_class' => 'genesis-nav-menu js-superfish sf-js-enabled sf-arrows' ) );
        echo'</div>';
    }
}