wp_create_nav_menu( string $menu_name )
Creates a navigation menu.
Description Description
Note that $menu_name
is expected to be pre-slashed.
Parameters Parameters
- $menu_name
-
(string) (Required) Menu name.
Return Return
(int|WP_Error) Menu ID on success, WP_Error object on failure.
Source Source
File: wp-includes/nav-menu.php
function wp_create_nav_menu( $menu_name ) { // expected_slashed ($menu_name) return wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
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:
Expand full source codeCollapse full source code