You could do this with a filter on wp_get_nav_menu_items
.
In this example, we first check if it’s the admin screen or the user is not logged in, and bail out if that’s the case.
Then we look at each menu item and find the one with Log In
as the menu item title, and unset it.
function wpa_remove_menu_item( $items, $menu, $args ) {
if( is_admin() || ! is_user_logged_in() ) return $items;
foreach ( $items as $key => $item ) {
if ( 'Log In' == $item->title ) unset( $items[$key] );
}
return $items;
}
add_filter( 'wp_get_nav_menu_items', 'wpa_remove_menu_item', 10, 3 );
Related Posts:
- Mega Menu Walker
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- start_lvl Ignored in Custom walker_nav_menu
- Displaying Logged-In User Name in WordPress Menu
- Logout and redirect using the WP Menu
- Run a filter when a walker runs
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Automatically adding new post categories to menu
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- Nav-Menu not showing up
- Add parent menu item in sub-menu in custom nav_walker
- Add the “.current-menu-item” class to tag?
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- Hide main div if wp_nav_menu is empty
- Check if a menu is empty?
- How to remove a metabox from menu editor page?
- Walker class: Problems with understanding how walk() method can be called without error
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to add active class to custom menu using while loop and wp_list_pages
- WordPress menu deletes when trying to add a hook
- Second Navigation inside header
- How can I add a custom class to only nav sub-menu > li > a items in WordPress?
- items_wrap not working
- Style wp_page_menu() items
- Have CSS Class Added with `is_page()` WP function
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Can’t extend some core classes
- Change Navigation Bar based on logged in or not
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- How do I create page navigation linking to each H2 within the page? [closed]
- Multiple WordPress Menus that will only display all pages
- Menu — How to add “current-menu-grand-ancestor” css class
- WP Walker using custom css classes
- Menu Limitations
- Add data attribute to each li in menu
- Unique icons next to each WordPress menu item
- Child page menu in sidebar
- Title Case WordPress Menu Items
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Trying to store submenu items to render out after main menu
- How to change menu order item
- Add item to top of menu using a filter in functions.php
- Register a menu – Error Header
- How to style one item from main navigation?
- New walker for walker_nav_menu to change inside container data
- Add value to new attribute inside WordPress menu items
- Menu Custom Data Attributes
- How to display different submenus?
- Get the name of menu item with wp_nav_menu
- How to modify mobile nav menu text in theme
- How to add aria role and schema markup to custom walker container
- How can I use custom menus with a Bootstrap WordPress theme?
- Extend Menu Walker Output
- Custom navigation menu with awsAccordion
- Why can’t I add a custom image in my navigation?
- Remove submenu item from list
- Dynamic Menu drops pages?
- Remove the Tag from wp_nav_menu
- Menu not styling. New menus functionality giving me a headache
- Nav Walker that shows only children and siblings of top level parent menu item
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Adding markup to sub menu based on class
- I want to show cart items number if any or nothing, simple CART text
- How to set Nav as a default menu in wordpress
- How to put 2 php codes in functions.php without site crashing
- Menu not updating for logged in users after redirect
- Redirect User when they click Menu Option
- Add element after navigation element title don’t works like I expect
- Difference between “Walker_Nav_menu” and “walker”
- How to create a sub-page of sub-page?
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Pulling a variable into the wp_nav_menu function
- How I can add div to menu?
- WordPress adding in site URL to header links
- Custom Links in Walker Class
- Nav Menu Display
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- Open WordPress Page from selected option dropdown
- How to add different menu items on different menus?
- Nav menù doesn’t display selected pages
- Successful or Error Message after running mysql code in functions.php
- Use walker for specific menu, or avoid use of walker
- Adding Default Settings to Theme My Login plugin
- WordPress Gravatar filter is removing my custom attributes
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- How to list posts from a plugin taxonomy?
- My website is not showing Footer section
- Must filter functions receive all arguments passed to them?
- Displaying Slider in Front Page (home) using Customizr Theme
- How to add PHP pagination to wordpress
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Get Child of Child Pages in custom Menu
- Use WP_Query Data In Cookie
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- Pagination not displaying
- Setting WooCommerce currency programmatically
- Masking external links with internal link for member-only