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:
parent
77cf8a1184
commit
6385135983
@ -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
|
// get the first menu that has items if we still can't find a menu
|
||||||
if ( ! $menu && !$args->theme_location ) {
|
if ( ! $menu && !$args->theme_location ) {
|
||||||
$menus = wp_get_nav_menus();
|
$menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
|
||||||
foreach ( $menus as $menu_maybe ) {
|
foreach ( $menus as $menu_maybe ) {
|
||||||
if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
|
if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
|
||||||
$menu = $menu_maybe;
|
$menu = $menu_maybe;
|
||||||
|
Loading…
Reference in New Issue
Block a user