Adding Additional Menus In Genesis Child Themes

Here’s 2 options:

First: The code goes in your child themes functions file and creates one extra menu which displays in the genesis_after_header position.

There are 2 steps needed to add new nav menus.

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)

function register_additional_genesis_menus() {

register_nav_menu( 'third-menu' ,
__( 'Third Navigation Menu' ));
}
add_action( 'init', 'register_additional_genesis_menus' );

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' ) );
}

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

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.

You can also register multiple menus using register_nav_menus( $locations );

function register_multiple_menus() {

register_nav_menus( array(
'menu_three' => 'Menu Name',
'menu_four' => 'Menu Name',
    'menu_five' => 'Menu Name',
    'menu_six' => 'Menu Name'
) );
add_action( 'init', 'register_multiple_menus' );

Second: Genesis also includes a built in function which enables you to add theme support for additional menus.

This code goes in your child themes functions file and creates 6 nav menus.

remove_theme_support ( 'genesis-menus' );
add_theme_support ( 'genesis-menus' , array ( 
'primary' => 'Primary Navigation Menu' , 
'secondary' => 'Second Navigation Menu' ,
'third' => 'Third Navigation Menu' ,
'fourth' => 'Fourth Navigation Menu' ,
'fifth' => 'Fifth Navigation Menu' ,
'six' => 'Six Navigation Menu' 
) );

add_action( 'genesis_after_header', 'genesis_do_more_navs' ); 

function genesis_do_more_navs() {

wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'genesis-nav-menu' ) );
wp_nav_menu( array( 'theme_location' => 'secondary', 'container_class' => 'genesis-nav-menu' ) );
wp_nav_menu( array( 'theme_location' => 'third', 'container_class' => 'genesis-nav-menu' ) );
wp_nav_menu( array( 'theme_location' => 'fourth', 'container_class' => 'genesis-nav-menu' ) );
wp_nav_menu( array( 'theme_location' => 'fifth', 'container_class' => 'genesis-nav-menu' ) );
wp_nav_menu( array( 'theme_location' => 'six', 'container_class' => 'genesis-nav-menu' ) );

}

You can wrap each in an existing class or wrap the lot in an existing or new menu class.

Clearly, these are not the only methods you can use to add new menus in WordPress or Genesis however its a good option for child theme users where Genesis supports the use of custom functions rather then editing parent theme template files.

Source http://codex.wordpress.org/Function_Reference/wp_nav_menu

Leave a Comment

tech