Skip to content

Commit

Permalink
Amend ordering params to approximate current wp_nav_menus behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Nov 23, 2021
1 parent d6d1e25 commit 2831ff3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
);

Expand Down

0 comments on commit 2831ff3

Please sign in to comment.