Pls use filter wp_nav_menu_{$menu->slug}_items
for conditionally adding or removing the menu-items.
https://developer.wordpress.org/reference/hooks/wp_nav_menu_menu-slug_items/
See Method 2 at: https://wordpress.stackexchange.com/a/31753/116231
Related Posts:
- Is there an easy way to replace a custom menu link with a page or post?
- Why do Custom Nav Menus generate so many classes on list items? Can I manage this somehow?
- Custom search filter causes menu and query_posts problems
- Add separator to admin submenu
- Using nonce in menu item
- How do I add nested categories to drop-down menu in twenty-eleven?
- Add custom page link with anchor
- How show sub menu only using wp_nav_menu()
- How to add menu to Dashboard that can be viewed by all users
- List children of second level sub page
- Show top-level parent with submenu menu walker
- Add section to custom menu panel
- Adding menu items dynamically using wp_nav_menu_objects
- BuddyPress – How to add logout in nav menu
- Highlight the “Home” / “Blog” button while on main page
- How to remove div container in custom menu?
- how to add Custom menu item like User name in Header Menu only
- Display three different levels of navigation from wp_nav_menu separately?
- Menus – Open items in new tab/window?
- Highlight another nav item
- How to translate menu items?
- echo same menu items across multi-site platform
- Custom Menu url is Empty
- Get category ID from nav menu
- How to make link to different categories that in them selves loads different menus?
- Menus don’t appear in admin area / WordPress Multisite
- Programmatically add existing pages and subpages to Appearance Menu
- Highlight current post ancestor parent menu items
- Ad custom admin page like WordPress customizer [closed]
- wp_nav_menu() doesn’t work
- Insert other menus as submenus of a main menu
- Appearance Menus Screen – menu item drop down menu not functioning
- Weird behaviour on Edit Menus screen
- Make a navigation menu in the same post [duplicate]
- Count within foreach loop
- How to actually make menu walker alive on admin interface?
- Highlight parent if item from submenu is active
- How to exclude pages in the menu without pageID?
- changing host.. data loss
- Theme Location empty
- Replace the slug of parent pages with # [closed]
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- How to avoid a duplicate query from using wp_nav_menu?
- Wrapping menu’s top-level link and sub-menus in div
- Page appears after de registering from menu
- login logout menu changes in wordpress [closed]
- Style wp_link_pages as a select drop down list
- functions.php adding item to end of menu. I want to change position
- Plugins & Setting Menu Items Removed From Admin Panel
- Custom Menu Anchor Links Not Working
- Responsive menu on genesis theme [closed]
- Question about Menus on WordPress
- Switching to child theme breaks menu names
- Controlling sub-menu within sub-menu
- Main menu navigation links and new pages
- Bootstrap menu – make menu entries with submenu not clickable
- Styling issue with custom menus and sub menus
- When I click a custom menu link, how do I make it update the URL in the browser to the external link?
- Duplicate menu items when auto generating menu from product categories
- Using menus to link to sections on the home page
- Multisite: menus can’t be added in child sites
- How to change the navigation menu
- Menu links URL with PHP GET method
- WordPress nav_menu items from another menu appearing
- Is it possible to remove the highlighted menu on Users and highlight a different menu?
- Adding widget to sidebar which contains current page’s submenu
- How To add this tag before drop-down ul. in wordpress
- Unable to get Navigation Menu to display in the desired location
- WordPress theme editor not showing
- How to switch menu location in this header.php?
- Why does WordPress convert absolute URLs to relative URLs for menu items?
- Extending Walker_Nav_Menu in wp_nav_menu List of Empty Items
- Jump to section on another page from menu item
- Users are required to login to my site. How define user.member boolean, its permissions, and conditionally display/handle behavior based on it
- How to Use Default Auto-Generated Menu?
- How to sort a sub-menu, generated with get_pages(), by the page order instead of alphabetically?
- Adding a menu item to the main menu
- wp_is_mobile() inside js
- Adding two same css class on menu item
- Two questions about CSSing inside the menus
- Any reason why widgets/menus get emptied when I updated custom theme code?
- Add items to a menu
- How to change page location in WordPress
- Use menu structure for permalinks
- Add tooltips with image in WordPress Menu?
- How to make a drop down menu with categories
- How to use my custom menus as seperate pages?
- how to keep theme background image, menu or site header image while moving site in sub directory?
- Unable to edit Navigation bar
- Editor user only allow to post on certain categories
- Menu Underline shows without Hover after adding subitems
- Add class to current category menu item
- WordPress wp get nav menu items does not deliver external link
- Should I custom code drop down menus or use a wordpress plugin?
- How to load css file in my menu in wordpress
- Site pages show the page title under navigation bar
- Navigation menu, remove item from desktop
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Wrapping my ‘s with
- Add acf custom fields so sub item in menus