Latest Tech and Tips

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

0

The Twenty Ten theme solely comes with one default menu, which is included in the header. However the theme additionally helps a number of menus, thanks to the use of  register_nav_menus(). Here’s a fast tip on how to make the most of this perform and add a second menu to the Twenty Ten theme.

Watch the Screencast

Functions.php

Open the capabilities.php file and search for:

// This theme makes use of wp_nav_menu() in a single location.

The subsequent line is the place we see the register_nav_menus() getting used. As you may see this perform accepts an array.

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

main: that is a key, or title of the menu, this title needs to be distinctive inside the array

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

To add the second menu merely add one other key (menu title) and assign a worth (enter description) into the array. Here’s an instance of what it may well seem like when including your second menu:

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

This approach can be utilized in creating different free themes or little one themes as nicely. If you will have any questions, be happy to ask in the remark.