The bug is not in this snippet of code. The problem is with how you call wp_get_nav_menu_array
, wherever that happens. The $current_menu is likely something invalid, so wp_get_nav_menu_items
returns false
, and thus you get the error that you get.
You can see in user contributed notes an example of how to get a valid value for $current_menu https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/#user-contributed-notes
Related Posts:
- Remove Container Element From wp_nav_menu() Markup
- Breadcrumbs showing Parent and Child Pages
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- automatically adding submenu items
- Logout hyperlink within a sub-menu
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- How do I create page navigation linking to each H2 within the page? [closed]
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- Custom Nav Walker sub-menu
- Categories as main menu items and subcategories as nested lists
- Secondary Menu and Logged In Users
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Default Nav Highlight
- why is this function firing on all child menu items as well?
- Multiple navigation menu in same location
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Conditional custom menu?
- Bizarre Child Menu Issue on WP Site
- How to automatically add counted number to navigation menu items?
- How to add widget in main menu
- Modify sub_menu function to show pages below a specifically set page
- How do I get my nav menu to show sub pages?
- How to add a data attribute to a WordPress menu item
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Mega Menu Walker
- Get menu object from theme_location
- Displaying Logged-In User Name in WordPress Menu
- Remove a menu item created by a plugin
- Using wp_get_nav_menu_items() to list children of children pages
- How to target specific wp_nav_menu in function?
- Multi Level Bootstrap Navigation Menu in WordPress
- Show only 2nd level of navigation depending on active navigation
- Custom menus displaying all pages instead of set pages
- How to manually add an item to a submenu in a menu generated by wp_nav_menu?
- How to activate “Description” metabox for menu item programmatically?
- Dynamically add sub-categories to any category in the menu
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Two different menus for two different locations?
- Custom Nav Walker sub-menu HTML construct
- Unregister Nav Menu with fallback?
- Generate a tabbed submenu — from taxonomy term or submenu item — with sample content
- Adding different classes to anchor in navigation menu
- How to programmatically set a menu to be the Primary Menu?
- Editing or filtering the output of the Genesis navigation
- how to automatically generate hierarchical menus from hierarchy of pages?
- Logout and redirect using the WP Menu
- How to display dynamic content in start_lvl function
- Make menu structure match page heirarchy on page parent change
- Menus like a CMS
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- Is there a way to add a class to non current menu item?
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- CSS for menu item added via functions.php
- How To Remove Duplicate Menu Locations
- Check if menu id = $specific_id – then insert specific
- Where do I add html code to the menu div?
- Breadcrumbs – Exclude Child Categories
- Replace menu links with # and add name to its li
- Function issue with Walker_Nav_Menu [duplicate]
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- wp_nav_menu() with multiple Class
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Make parent page only link to first subpage
- How to add nav menu items to a specific position within a menu
- wp_nav_menu, walker class, categories as classes of li
- Hard-coding custom menu elements for menu manager
- Trying to Create Menu in WordPress
- How do I add recent posts to the menu?
- Automatically list top level menu item child pages
- How to fetch the name of the active menu?
- Check if menu_item has children or has parent
- Replace a menu with widget or a custom template file programmatically
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- How to get correct URLs in network wide menu (Multisite)?
- Removing specific menu items?
- append to existing parent theme function
- Add a submenu to wp_nav_menu
- How do I hook into the container of wp_nav_menu?
- Add login hyperlink to secondary navigation menu
- How can I add a delay to the collapsible menu in Twenty Eleven?
- Give Children Unique ID’s
- New custom menu created. how to apply it?
- Dropline menus — seperators between children only?
- Filter nav menu items HTML tags and wrap inner text with span
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- Change menu based on page template via functions.php
- Show some menu sub items as dropdown under a menu item
- Adding toggle-able element after menu item
- How to add custom li item to wordpress menu
- Different methods of adding menu support to custom theme
- Adding a section in line at the end of the main navigation menu in php
- How to Add support for sub-menu item description in wordpress?
- wp_nav_menu work in functions.php but not in the theme
- How to register a menu based on a ACF condition