#30684 closed defect (bug) (invalid)
has_nav_menu falsely returns false
Reported by: | melissahsiung | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.0.1 |
Component: | Menus | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
has_nav_menu returns false even when a user creates a custom nav menu.
Change History (4)
#2
@
10 years ago
- Keywords reporter-feedback added
has_nav_menu()
is not supported to return true until the user actually has created a menu and then assigned that menu to the menu location in question.
Tested on WP 4.2-alpha (trunk, no plugins, Twenty Fifteen, a menu is assgned to 'primary') with the code you provided on StackExchange:
1) Checking for 'primary': true
2) No menu assigned to location 'global-nav': false
3) After a menu assigned to the location 'global-nav': true
Also tested on a live 4.0.1 installation with same results. So I can't confirm this neither in trunk nor in 4.0.1.
Have you tested with no plugins, the default theme and after assigning a non-empty menu to the location "Global NAvigation" under Appearance - Menus?
more details: http://wordpress.stackexchange.com/questions/159939/why-does-has-nav-menu-return-false-when-get-registered-nav-menus-shows-the-oppos