Free Wordpress Blog Setup

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

By Editorial Staff in Tutorials
Video: Adding a Second Menu to the WordPress Twenty Ten Theme

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.

What Next?

Digg it
Save This Page
Subscribe to WPBeginner
Stumble it
Free Wordpress Blog Setup

Comments

6 Responses to “Video: Adding a Second Menu to the WordPress Twenty Ten Theme”
  1. Ben Joven says:

    Nice…I like how you move the cursor super slow!!!

  2. Khaled Hakim says:

    Thank you for concise and to the point explanation. Appreciate the time you put into helping others by posting such helpful information.

    I’m bummed that twentyten came with only one menu though. They should’ve atleast created two!

    Thanks Though… looks easy enough.

  3. Celia says:

    Great tutorial, thanks. I was wondering how to use this for a child theme. I’m a novice to the functions.php and am not sure how to go about using the unhook filter instructions given by the wordpress codex.

  4. Celia says:

    I created a child theme…a lot of trial and error since I’m new to that too. But could not get the menu right. Something went screwy with the primary navigation and I’m trying to figure out why. I’d created another menu in the menu manager but when I try to use it as the primary navigation, the entire menu bar disappears. I was wondering if it’s because I’d changed the header size.

    In searching around for an answer, your tutorial seemed the more plausible fix.

  5. Celia says:

    I think i figured out why the menu bar was completely disappearing. But I’d still like to add the second menu into the child’s function.php instead of changing it through the dashboard’s editor.

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar