wp_create_nav_menu()创建一个新的前台导航菜单

目录

描述

Create a Navigation Menu. This function can be used to programmatically create a navigation menu which will be added to the Menus page under Appearance.

wp_create_nav_menu() 描述

用法

<?php $menu_id wp_create_nav_menu($menu_name?>

wp_create_nav_menu() 用法

参数

$menu_name

(string) (必填) The title of the menu to create.

默认值: None

wp_create_nav_menu() 参数

返回值

(int|WP_Error) 

The Menu ID or WP Error Object in case of failure.

wp_create_nav_menu() 返回值

示例

To check if a menu exists first and then create it if it doesn't exists, and finally add menu items to it, use:

wp_create_nav_menu() 示例

源文件

wp_create_nav_menu() 函数的代码位于 wp-includes/nav-menu.php.

wp_create_nav_menu() 源文件

相关