Adding Additional Menus In Genesis Child Themes

I have a Genesis child theme that I bought, and it only supports two menus, a primary and a secondary. However, for what I would like to do with my site I need to have 6 menus all together.

This is my website http://thenottypicalarmywife.com

Read More

This is what I want the menus to look like http://livingwellspendingless.com with the menus across the top of the page.

Related posts

4 comments

  1. 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

  2. You should register your new menu first, usually in functions.php:

    add_action( 'after_setup_theme', 'the_theme_setup' );
    function the_theme_setup() {
        // Register mymenu
        register_nav_menu( 'mymenu', __('My Menu' ) );
     }
    

    Then, in the admin menu manager you can build the menu and assing it to the new menu location you have previously register. After that, you can render the menu where you want it to be displayed in your theme:

    //For more params see http://codex.wordpress.org/Function_Reference/wp_nav_menu
    wp_nav_menu( array(
                       'theme_location' => 'mymenu',
                      ) );
    
  3. The above answer are all acceptable, however there are special genesis functions to add menus, so register_nav_menu as well as wp_nav_menu don’t need to be used… If your using genesis you might as well take advantage of their functions!


    This is the preferred way in Genesis 2.0+ to add genesis menu support in child themes:

    //* Start the engine - include this at begining of theme
    include_once( get_template_directory() . '/lib/init.php' );
    
    // Add support for footer menu - doesn't need to be hooked into anything...
    // Include theme support for menus and everything else genesis here
    add_theme_support ( 'genesis-menus' , array ( 
        'primary'   => __( 'Primary Navigation Menu', 'genesis' ),
        'secondary' => __( 'Secondary Navigation Menu', 'genesis' ),
        'footer'    => __( 'Footer Navigation Menu', 'genesis' )
    ) );
    
    // Hook into genesis_footer early to output custom menu 
    add_action( 'genesis_footer', 'wpse_genesis_custom_footer_menu', 9 );
    function wpse_genesis_custom_footer_menu() {
        genesis_nav_menu( array(
            'theme_location'  => 'footer',
            'container'       => 'div',
            'container_class' => 'menu-wrap',
            'menu_class'      => 'menu genesis-nav-menu menu-footer list-inline',
            'depth'           => 1
    ) );
    }
    
    // OPTIONAL - Add genesis attributes for semantic markup  
    add_filter( 'genesis_attr_nav-footer', 'gb3_add_nav_footer_attr' );
    function gb3_add_nav_footer_attr( $attributes ){
        $attributes['role'] = 'navigation';
        $attributes['itemscope'] = 'itemscope';
        $attributes['itemtype'] = 'http://schema.org/SiteNavigationElement';
        return $attributes;
    }
    
    // OPTIONAL - Add .wrap class
    add_theme_support( 'genesis-structural-wraps', array(
        'header',
        'nav',
        'subnav',
        'site-inner',
        'footer-widgets',
        'footer',
        'nav-footer'
    ) );
    
  4. Create your menus in the admin, then use <?php wp_nav_menu( array('menu' => 'Menu Name' )); ?> to place them in your templates.

    That would be the easiest method.

Comments are closed.