From 63851359839b90e0896a173e2f4b9ce1b3f7c238 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 24 Jun 2014 17:24:23 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@28826 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/nav-menu-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php index 7956bc6c52..a820c55a97 100644 --- a/src/wp-includes/nav-menu-template.php +++ b/src/wp-includes/nav-menu-template.php @@ -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;