From 2831ff35cf6373a75fac2a983e0e7b1a8ba35f23 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 23 Nov 2021 14:26:09 +0000 Subject: [PATCH] Amend ordering params to approximate current wp_nav_menus behaviour --- packages/block-library/src/navigation/index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index ea8fbd43df055..e421aef4ab02d 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -139,10 +139,15 @@ function block_core_navigation_render_submenu_icon() { * @return WP_Post|null the first non-empty Navigation or null. */ function block_core_navigation_get_non_empty_navigation() { + // Order and orderby args set to mirror those in `wp_get_nav_menus` + // see: + // - https://github.com/WordPress/wordpress-develop/blob/ba943e113d3b31b121f77a2d30aebe14b047c69d/src/wp-includes/nav-menu.php#L613-L619. + // - https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters. $navigation_posts = get_posts( array( 'post_type' => 'wp_navigation', - 'order' => 'DESC', + 'order' => 'ASC', + 'orderby' => 'name', ) );