函数原型
register_nav_menus( string[] $locations = array() )
函数描述
Registers navigation menu locations for a theme.
是否弃用
未弃用
函数参数
-
$locations
string[]
Optional - Associative array of menu location identifiers (like a slug) and descriptive text.
Default:
array()
函数返回值
无
函数位置
File: wp-includes/nav-menu.php.
函数源码
function register_nav_menus( $locations = array() ) {
global $_wp_registered_nav_menus;
add_theme_support( 'menus' );
foreach ( $locations as $key => $value ) {
if ( is_int( $key ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Nav menu locations must be strings.' ), '5.3.0' );
break;
}
}
$_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |

