WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/register nav menu

Description

Registers a single custom Navigation Menu in the custom menu editor (in WordPress 3.0 and above). This allows administration users to create custom menus for use in a theme.

See register_nav_menus() for creating multiple menus at once.

Usage

 <?php register_nav_menu$location$description ); ?> 

Parameters

$location
(string) (required) Menu location identifier, like a slug.
Default: None
$description
(string) (required) Menu description - for identifying the menu in the dashboard.
Default: None

Return Values

None.

Examples

<?php
add_action( 'after_setup_theme', 'register_my_menu' );
function register_my_menu() {
  register_nav_menu( 'primary', __( 'Primary Menu', 'theme-slug' ) );
}
?>

Notes

  • This function automatically registers custom menu support for the theme therefore you do not need to call add_theme_support( 'menus' );
  • This function actually works by simply calling register_nav_menus() in the following way:
    register_nav_menus( array( $location => $description ) );
  • Use wp_nav_menu() to display your custom menu.

Change Log

Source File

register_nav_menu() is located in wp-includes/nav-menu.php.

Related

Navigation Menu

See also index of Function Reference and index of Template Tags.