unregister_nav_menu() - WordPress 函数参考中文文档

返回介绍

unregister_nav_menu()

发布于 2017-09-11 字数1707 浏览 951 评论 0

unregister_nav_menu( string $location )

Unregisters a navigation menu location for a theme.


描述


参数

$location

(string)
(Required)
The menu location identifier.


返回值

(bool) True on success, false on failure.


源代码

File: wp-includes/nav-menu.php

function unregister_nav_menu( $location ) {
	global $_wp_registered_nav_menus;

	if ( is_array( $_wp_registered_nav_menus ) && isset( $_wp_registered_nav_menus[$location] ) ) {
		unset( $_wp_registered_nav_menus[$location] );
		if ( empty( $_wp_registered_nav_menus ) ) {
			_remove_theme_support( 'menus' );
		}
		return true;
	}
	return false;
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/theme.php:
    _remove_theme_support()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Basic Example

    
    <?php unregister_nav_menu( 'primary' ); ?> 
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!