WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#25258 closed defect (bug) (worksforme)

Notices when no items in nav menu

Reported by: mordauk Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: Menus Keywords: reporter-feedback 2nd-opinion
Focuses: Cc:

Description

When displaying a nav menu with wp_nav_menu() there are a lot of notices if the nav menu is created but has no nav items:

Some sample notices shown in the attached screenshot.

Attachments (2)

Screenshot from 2013-09-08 20:14:13.png (115.2 KB) - added by mordauk 8 years ago.
Notices
Screenshot from 2013-09-08 20:15:00.png (38.9 KB) - added by mordauk 8 years ago.
nav menu with no items

Download all attachments as: .zip

Change History (6)

@mordauk
8 years ago

nav menu with no items

#1 @SergeyBiryukov
8 years ago

  • Keywords reporter-feedback added; needs-patch removed

Could not reproduce on a clean install:

  1. If there are no menu items, wp_nav_menu() falls back to wp_page_menu() by default:
    tags/3.6/wp-includes/nav-menu-template.php#L180.
  2. If I specify an empty fallback_cb parameter to disable the default fallback, then the walker is called via walk_nav_menu_tree(), but it bails out early if there are no items:
    tags/3.6/wp-includes/class-wp-walker.php#L182.

Tested in both 3.6 and current trunk. Could you provide the exact steps to reproduce?

#2 @nofearinc
8 years ago

  • Keywords 2nd-opinion added

Can't reproduce here either, seems like the walker has been called on Pippin's setup and trying to work with empty $item being passed, but I can't replicate that use case either (by using the menu or theme_location arguments for wp_nav_menu).

#3 @nacin
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

#4 @SergeyBiryukov
8 years ago

  • Version changed from trunk to 3.6
Note: See TracTickets for help on using tickets.