Used this for GB Dog Training site. Needs a secondary menu for services page.
https://wpsites.net/web-design/adding-additional-nav-menus-in-genesis/
//* 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 - see conditional alternative in functions-gbdog-conditional.php
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 - add conditional (see code below provided by Mike Hemberger)
<?php
// conditional code included
// Add services navigation menu - only on services page - ASK Design
// Mike Hemberger method
function register_services_genesis_menus() {
register_nav_menu( 'services-menu' ,
__( 'Services Navigation Menu' ));
}
add_action( 'init', 'register_services_genesis_menus' );
add_action( 'genesis_before_content', ask_add_services_nav' );
function ask_add_services_nav() {
if ( ! is_page( 9 ) ) {
return;
}
// My code
echo'<div class="nav-services">';
wp_nav_menu( array(
'theme_location' => 'services-menu',
'container_class' => 'genesis-nav-menu' ) );
echo'</div>';
}
// end of third nav menu custom code - ASK Design
// Sallie Goetsch method - doesn't work
if (is_page('9') {
add_action( 'genesis_before_content', 'add_services_nav' );
function add_services_nav() {
//function code
}
}
// Mike Hemberger method - used above - works!
add_action( 'genesis_before_content', 'prefix_add_services_nav' );
function prefix_add_services_nav() {
if ( ! is_page( 9 ) ) {
return;
}
// My code
}