Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55893 new defect (bug)

Not able to save navigation menus and not able to retrieve menus using wp_get_nav_menu_items

Reported by: huskyr's profile huskyr Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0
Component: Menus Keywords:
Focuses: administration, template Cc:


i'm having some issues with navigation menus since upgrading WordPress from 5.9.3 to 6.0.0. In two custom themes i've built i notice the following behaviour:

  • Using wp_get_nav_menu_items does not return anything when trying to fetch the menu items for a given id.
  • When using the 'Menus' option in the Appearance menu items added to the menu don't show up. I can add new menus, and even add items to it. But when i press 'Save Menu' and reload the page they dissappear.

I've bumped my head around this for two hours but i can't find anything that i'm doing wrong. A couple of things i noticed:

  • This has definitely something to do with the 6.0 upgrade. When going back to 5.9.3 the problem doesn't occur.
  • The items do seem to be added to the database, they just don't display anymore on the site.
  • I've got a hunch this might be related to #54905, which i've also run into.
  • When switching to the twentytwenty and twentytwentyone themes things work as normal. I can also see the menu items i've added in my custom theme that don't appear there.
  • I'm not using any activated plugins.

Change History (1)

#1 @huskyr
2 years ago

Answering my own bug here: it seems this went wrong because i had a pre_get_posts action that set the post_type to a custom type for every query. Adding a $query->is_main_query() to that action fixed it. I'm still unsure why this did work in <6.0 versions.

Note: See TracTickets for help on using tickets.