Commit c5d6a668a3 for wordpress.org
commit c5d6a668a3d91cee59cfd078c3f59a0ca3eccfed
Author: audrasjb <audrasjb@git.wordpress.org>
Date: Tue Nov 17 14:49:00 2026 +0000
Menus: Fix wp_get_nav_menu_items() dropping items when the term count is stale or the query is not publish-only.
This changeset replaces the `$menu->count` short-circuit with `get_posts( $args )` as `$menu->count` is not a safe proxy for "no items match these args". `get_posts()` already returns `array()` for a empty menu, and that query is cached in the persistent `post-queries` group.
Developed in https://github.com/WordPress/wordpress-develop/pull/13513.
Props myththrazz, ugyensupport, rashmicodewing, ravipatel.
Fixes #66102.
Built from https://develop.svn.wordpress.org/trunk@65554
git-svn-id: http://core.svn.wordpress.org/trunk@64627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php
index 40612d5b8d..191c8d0648 100644
--- a/wp-includes/nav-menu.php
+++ b/wp-includes/nav-menu.php
@@ -734,12 +734,8 @@ function wp_get_nav_menu_items( $menu, $args = array() ) {
),
);
$args = wp_parse_args( $args, $defaults );
- if ( $menu->count > 0 ) {
- $items = get_posts( $args );
- } else {
- $items = array();
- }
+ $items = get_posts( $args );
$items = array_map( 'wp_setup_nav_menu_item', $items );
if ( ! is_admin() ) { // Remove invalid items only on front end.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 8552b6ec12..5783ecffa2 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta5-65553';
+$wp_version = '7.2-beta5-65554';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.