From cc0c90e05a74853149697a0193a274f2d4490be7 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 24 Jun 2014 17:25:15 +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. Built from https://develop.svn.wordpress.org/trunk@28826 git-svn-id: http://core.svn.wordpress.org/trunk@28630 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index 7956bc6c52..a820c55a97 100644 --- a/wp-includes/nav-menu-template.php +++ b/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;