You can try the !is_admin()
so your code would be:
function wpse31748_exclude_menu_items( $items, $menu, $args ) {
// Iterate over the items to search and destroy
if ( !is_admin() && is_user_logged_in() ) {
$registerpage = get_page_by_title( 'Register' );
$loginpage = get_page_by_title( 'Login' );
foreach ( $items as $key => $item ) {
if ( $item->object_id == $registerpage->ID ){
unset( $items[$key] );
}elseif ( $item->object_id == $loginpage->ID ){
unset( $items[$key] );
}
}
}
return $items;
}
add_filter( 'wp_get_nav_menu_items', 'wpse31748_exclude_menu_items', null, 3 );
Related Posts:
- What is a good resource to find out about making custom walkers?
- Comment Walker vs. Comment Callback
- Why is my menu order not working with wp_nav_menu?
- Incrementing a class in a custom walker
- Adding ul class with wp_list_categories Custom Walker
- how to conditionally add attributes to start_lvl() function?
- Menu location by menu id or menu ID in start_el() Walker
- Adding dynamic content to end_lvl in Walker Class [closed]
- Walker gives additional taxonomy name?
- $args->has_children not working with start_el()
- ol children instead of ul children
- Extend Walker Class for 2 checkbox taxonomy selection?
- using walker menu to add classes and attributes to elements
- Custom megameu walker need improvement
- List pages to show only Whitelisted sub pages
- Get Parent List Class for Child Pages Using Walker
- Manual use of Walker_Category class
- How do I get_the_content in a custom walker?
- Creating Custom navigation in wordpress with sub menus
- Page thumbnail doesn’t display on navigation
- How to remove ul & li from wordpress custom walker?
- Is it possible to display the Navigation Menu without using Walker_Nav Class
- Walker_Category – not reliably saving
- Custom Walker menu depth opening problem
- How to append something before final tag in walker class?
- Using wp_list_categories or other function inside a menu walker?
- Walker to add Bootstrap markup for wp_list_pages
- Help with output of post classes using apply_filters
- Custom walker pulldown display current page
- Custom Nav walker display current menu item children, or siblings on no children
- Add a custom walker to a menu created in a widget
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- Any walker causes blank menu?
- Admin Panel – Disable Moving Selected Terms To Top of Metabox
- Custom Nav Walker menu – Display children count
- Using string instead of object class instantiation on the walker argument breaks wp_nav_menu
- automatically placing custom post types singles into submenu of main nav menu
- Adding attributes to link in wp_nav_menu using custom Walker function
- Walker_Nav_Menu: put custom code between a particular
- Adding Post Counts to Menu (Nav) Programmatically?
- Show top-level parent with submenu menu walker
- Adding a class (arrows) to main menu links that have children?
- Adding html elements to wp nav menu
- Bar separated navigation by extending Walker_Nav_Menu
- Does the ‘nav_menu_css_class’ filter accept 2 or 3 arguments?
- Add div to specific sub-menu
- wp_nav_menu custom walker – child items
- Getting post content within wp_nav_walker
- Walker nav remove submenu ul from a certain depth
- Removing from Comment
- Insert HTML inside link in a walker
- Make wp_list_pages print slugs instead of titles
- Make parent page only link to first subpage
- How do I separate link levels in a custom menu walker?
- custom walker wp menu last element
- Remove unwanted elements for a wp_nav_menu
- Is this format possible with a custom Nav Walker class?
- Difference between walker class and basic php
- Custom navigation structure with walker class
- Custom Navigation build using wp_nav_menu and walker
- How do you add a around the second level of a Menu?
- Troubles with Walker_Nav_Menu and closing
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- How to add class to parent a tag with a sub menu
- Help with walker for nav
- Dynamic_sidebar inside wp_nav_menu
- Why is only the first operation run in my loop – except for on the last repeat? [closed]
- How Do I Add Images To Main Navigation Menu
- New walker for walker_nav_menu to change inside container data
- How to add a element with walker menu right after begin of the navigation tags?
- How can I apply filters in my class that extends Walker_Nav_Menu?
- WordPress Nav Walker – Top menu link with dropdown link not clickable (dropdown opens)
- Displaying Nav Menu
- Implement a Walker with custom object rather than WordPress database object
- Add custom class to li element which has children
- How to add custom class to get_avatar()
- Set custom id to list element walker custom function
- Modifying navigation menu classes with a Walker
- changing the labels inside appearance -> menus for some for the fields
- Check is category parent with ids from the childs – get_term_children
- Walker_Nav_Menu creating too many closing tags?
- wp_dropdown_categories() show elements checkbox
- WordPress change wp_nav_menu walker with a custom one
- WordPress custom menu can’t show 3. level submenu
- Nav Walker that shows only children and siblings of top level parent menu item
- Hook or callback when wp_nav_menu() has completed
- Help with WordPress Custom Nav Walker
- Does the Default theme of WordPress like 2016, 2017 and 2019 uses Walker_Nav_Menu Class
- how to split vertical menu into two columns using walker nav menu
- Extending Walker_Nav_Menu in wp_nav_menu List of Empty Items
- How to Display image from Menu Image in Walker Dropdown Select Menu
- Custom menu with Walker class – what should the $db_fields be?
- How can I edit submenu headings using wp_nav_menu walker?
- Can’t add optional class to menu item when using Walker_Nav_Menu
- Override edit_custom_walker.php to conditionally show input depending on menu position
- Strict Standards Error bootstrap navwalker
- Determine if a navigation item has children
- wp_nav_menu – Collapse with PHP
- custom walker to add iconfont to wp_nav_menu
- WordPress nav Walker – Bootstrap 5.2.3 – submenu not opening