Video: Adding a Second Menu to the WordPress Twenty Ten Theme

103

The Twenty Ten theme only comes with one default menu, which is included in the header. However the theme also supports multiple menus, thanks to the use of  register_nav_menus(). Here’s a quick tip on how to take advantage of this function and add a second menu to the Twenty Ten theme.

Watch the Screencast

Functions.php

Open the functions.php file and look for:

// This theme uses wp_nav_menu() in one location.

The next line is where we see the register_nav_menus() being used. As you can see this function accepts an array.

register_nav_menus( array(  'primary' => __( 'Primary Navigation', 'twentyten' ),  ) );

primary: this is a key, or name of the menu, this name should be unique within the array

__( ‘Primary Navigation’): this is the vaule of the key, or description of the menu

To add the second menu simply add another key (menu name) and assign a value (enter description) into the array. Here’s an example of what it can look like when adding your second menu:

  register_nav_menus( array(  'primary' => __( 'Primary Navigation', 'twentyten' ),  'secondary' => __( 'Secondary Navigation', 'twentyten' ),  ) );

This technique can be used in creating other free themes or child themes as well. If you have any questions, feel free to ask in the comment.