WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#16605 closed defect (bug) (invalid)

wp_nav_menu fallback_cb argument ignored with using menu argument

Reported by: jonkirkman Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: Menus Keywords:
Focuses: Cc:

Description

wp_nav_menu ignores the fallback_cb argument when also using the menu argument.

If this is the expected behavior, it should be documented as it isn't intuitive.

This fails to honor the fallback_cb -

wp_nav_menu(array('menu' => 'mymenu', 'container' => 'false', 'fallback_cb' => ''));

This works as expected -

wp_nav_menu(array('theme_location' => 'mylocation', 'container' => 'false', 'fallback_cb' => ''));

Change History (1)

comment:1 in reply to: ↑ description @filosofo4 years ago

  • Keywords needs-patch 2nd-opinion removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to jonkirkman:

If this is the expected behavior, it should be documented as it isn't intuitive.

It is documented in the PHPDoc for wp_nav_menu. Is there somewhere else that it isn't documented correctly? (Codex has it, too.)

fallback_cb - If the menu doesn't exists [sic], a callback function will fire. Defaults to 'wp_page_menu'. Set to false for no fallback.

To elaborate, because you're specifying the menu, the only time the fallback_cb would apply is if that menu doesn't exist. In contrast, when you don't specify the menu, until one is assigned to that location the fallback_cb does apply.

Note: See TracTickets for help on using tickets.