Creates a navigation menu.
Description
Note that $menu_name is expected to be pre-slashed.
Parameters
$menu_namestringrequired- Menu name.
Source
function wp_create_nav_menu( $menu_name ) {
// expected_slashed ($menu_name)
return wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) );
}
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
Basic Example
To check if a menu exists first and then create it if it doesn’t exists, and finally add menu items to it, use: