wp_create_nav_menu

Creates a navigation menu.

Description

(int|WP_Error) wp_create_nav_menu( (string) $menu_name ); 

Note that $menu_name is expected to be pre-slashed.

Returns (int|WP_Error)

Menu ID on success, WP_Error object on failure.

Parameters (1)

0. $menu_name (string)
The menu name.

Usage

  1. if ( !function_exists( 'wp_create_nav_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu.php'; 
  3.  
  4. // The menu name. 
  5. $menu_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_create_nav_menu($menu_name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/nav-menu.php  
  1. function wp_create_nav_menu( $menu_name ) { 
  2. // expected_slashed ($menu_name) 
  3. return wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) );