WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/register nav menu

Contents

Description

Registers a single custom navigation menu in the new custom menu editor of WordPress 3.0. This allows for creation of custom menus in the dashboard for use in your 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
register_nav_menu( 'primary', 'Primary Menu' );
?>

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: register_nav_menus(), register_nav_menu(), unregister_nav_menu(), has_nav_menu(), wp_nav_menu(), wp_get_nav_menu_items()

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