WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#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 @knutsp
6 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 described as "Global Navigation" under Appearance - Menus?

Last edited 6 years ago by knutsp (previous) (diff)

#3 @knutsp
6 years ago

  • Resolution set to invalid
  • Status changed from new to closed

No feedback in 9 months, closing. Please reopen if this is really a bug, with detailed steps to reproduce.

#4 @SergeyBiryukov
6 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.