When selecting a fallback menu in wp_nav_menu(), the "first" menu is retrieved from an unsorted query. When retrieving a fallback menu, pass array( 'orderby' => 'name' ) to wp_get_nav_menus() to return a menu consistently.

Props lukecarbis.
Fixes #28126.

Built from https://develop.svn.wordpress.org/trunk@28826


git-svn-id: http://core.svn.wordpress.org/trunk@28630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-24 17:25:15 +00:00
parent 7b83df547d
commit cc0c90e05a

View File

@ -277,7 +277,7 @@ function wp_nav_menu( $args = array() ) {
// get the first menu that has items if we still can't find a menu
if ( ! $menu && !$args->theme_location ) {
$menus = wp_get_nav_menus();
$menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
foreach ( $menus as $menu_maybe ) {
if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
$menu = $menu_maybe;