register_nav_menu() WordPress Function

The register_nav_menu() function is used to register a custom navigation menu for a Wordpress site. This function takes two parameters: the menu location and the menu name. The menu location is the name of the theme location where the menu will be displayed. The menu name is the name of the menu.

register_nav_menu( string $location, string $description ) #

Registers a navigation menu location for a theme.


Parameters

$location

(string)(Required)Menu location identifier, like a slug.

$description

(string)(Required)Menu location descriptive text.


Top ↑

More Information

  • See register_nav_menus() for creating multiple menus at once.
  • 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 ) );
    
  • You may use wp_nav_menu() to display your custom menu.

Top ↑

Source

File: wp-includes/nav-menu.php

function register_nav_menu( $location, $description ) {
	register_nav_menus( array( $location => $description ) );
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.