Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

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

Last updated on by
Follow WPBeginner on YouTube
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.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • http://www.wpbeginner.com Editorial Staff

    Yes, you can use WordPress conditional statements and target each individual page, all single posts page, all archive pages etc.

  • http://jonathanbeairsto.info/ rtrivett

    I created and added the second menu (mirror’s the top one at the bottom) in the ‘twenty-ten-theme’ but it doesn’t display. Not sure how to make it visible???

  • wiredcanvas

    Very useful, thanks!

  • omermiron

    Hi.

    Can i use this as a second horizontal line (below primary navigation).

    I want to make it a submenu for one element of the primary menu.

    possible??

  • http://www.ipadstabber.com Mark Baynes

    Hi

    Thanks very much for this – short, sharp and to the point.

    mark

  • http://findyourbaseline.com Russ

    Help!

    I was trying to add a second menu…i have lost access to my sight adminstration. I now get the following page when I try to access my site or my site administration:

    Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /home4/findyow1/public_html/wp-content/themes/twentyten/functions.php on line 98

    how do i get back to the function.php to correct this error?

    also… it is obvious that i am not up to this task… are there themes where i will not have to go into the code?

    • http://www.wpbeginner.com Editorial Staff

      Remember you have curly quotes… make sure you fix those.

    • http://Www.kman.me Khaled Hakim

      Russ, you need to access your website hosting using FTP and then finding the functions.php file, downloading it and editing it with a text editor.

      If you need more help or directions email me: Khaled@kman.me

      Cheers.

      • http://findyourbaseline.com Russ

        Thank you Khaled. I have your email, and I am sure I will use it. I really want a very simple website, but I am struggling. I will do some more reading, and contact you if things do not become more clear. …Russ

  • http://findyourbaseline.com Russ

    I am a complete newbie. If I am understanding correctly, I must repeat the above directions for each menu I wish to add? so if I wanted to add a menu named “Articles” it would look like:

    register_nav_menus( array(
    ‘primary’ => __( ‘Primary Navigation’, ‘twentyten’ ),
    ‘Articles’ => __( ‘Articles Navigation’, ‘twentyten’ ),
    ) );

    • http://www.wpbeginner.com Editorial Staff

      yes that is correct.

  • jane

    I’d like a secondary horizontal menu to replace the main menu on certain pages for logged-in members only. Is this possible? Thanks

    • http://www.wpbeginner.com Editorial Staff

      Yes, that is possible. You are going to have to utilize the is_user_logged_in hook from the WordPress codex.

  • Himanshu vyas

    When I use this method to create secondry menus, my menus are duplicating each other. I also want to know how to create pages for secondry menus, I am confused little bit. Can you help me?

    • http://www.kman.me Khaled Hakim

      After following the above steps (editing the functions.php file found in your TwentyTen theme directory (http://yoursite/wp-content/themes/twentyten/functions.php ) you will need to log into your wordpress admin panel and click on Appearance (on the right hand side) and then click on MENUS. You will be able to add a new menu there. Make sure that you give this newly created menu the same name you gave it when you edited the functions.php file.

      As for pages under this menu… Simply create pages by clicking on Pages in the right hand menu of the admin control panel. Once you’ve added the pages you want, you can go back to Appearance > Menus > and select which pages you wish to add to your menus. You will be able to add pages easily.

      I hope I was helpful.

  • http://thebeardedfigtree.com Celia

    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.

  • http://thebeardedfigtree.com Celia

    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.

  • Celia

    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.

    • http://www.wpbeginner.com Editorial Staff

      Are you trying to create a child theme of your own? or are you trying to modify an existing one?

  • http://www.kman.me Khaled Hakim

    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.

  • http://angle45media.wordpress.com Ben Joven

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