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
This commit is contained in:
Scott Taylor 2014-06-24 17:24:23 +00:00
parent 77cf8a1184
commit 6385135983
1 changed files with 1 additions and 1 deletions

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;