Not tested, but it might work, use wp_logout_url()
wordpress in built function to get logout url.
// Add a Login hyperlink to the secondary navigation menu if the user is logged-out
function wpa_remove_menu_item( $items, $menu, $args ) {
if( is_admin() || ! is_user_logged_in() ) return $items;
foreach ( $items as $key => $item ) {
if ( 'Login / Register' == $item->title ) unset( $items[$key] );
if ( 'Logout' == $item->title ){$items[$key]->url=wp_logout_url();}
}
return $items;
}
add_filter( 'wp_get_nav_menu_items', 'wpa_remove_menu_item', 10, 3 );
Related Posts:
- Remove a menu item created by a plugin
- automatically adding submenu items
- Change position of media in admin menu
- Custom Nav Walker sub-menu
- retrieves menu and converts it to a readable array
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- why is this function firing on all child menu items as well?
- 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)
- Remove submenu item from list
- Conditional custom menu?
- Modify sub_menu function to show pages below a specifically set page
- Function Reference for custom link in Admin Menu Management 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
- Get menu object from theme_location
- Displaying the number of updates available in the Admin area
- Add separator to admin submenu
- How to remove Customize from admin menu bar after WP 4.3
- Modify Admin Bar Link
- Run functions only in the admin area?
- Using wp_get_nav_menu_items() to list children of children pages
- Reorder custom submenu item
- Breadcrumbs showing Parent and Child Pages
- Custom menus displaying all pages instead of set pages
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- difference between add_object_page and add_menu_page
- Dynamically add sub-categories to any category in the menu
- How to make pages metabox display all hierarchy in menu admin?
- Two different menus for two different locations?
- Print Dashboard menu name and link
- Unregister Nav Menu with fallback?
- How to programmatically set a menu to be the Primary Menu?
- Editing or filtering the output of the Genesis navigation
- how to only add a top-level admin menu without it creating a sub-level-menu
- Is there a way to add a class to non current menu item?
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- CSS for menu item added via functions.php
- How To Remove Duplicate Menu Locations
- Where do I add html code to the menu div?
- Replace menu links with # and add name to its li
- How do I create page navigation linking to each H2 within the page? [closed]
- Function issue with Walker_Nav_Menu [duplicate]
- Add Featured image column into wordpress admin on pages AND posts
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- 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
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- How to fetch the name of the active menu?
- Replace a menu with widget or a custom template file programmatically
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Categories as main menu items and subcategories as nested lists
- Creating A New Admin Menu Tab For Theme Options
- Admin: sub menu doesnt display under apperance when activate my themes
- Print Dashboard submenu name and filename
- How do I hook into the container of wp_nav_menu?
- New custom menu created. how to apply it?
- Dropline menus — seperators between children only?
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- Secondary Menu and Logged In Users
- Show some menu sub items as dropdown under a menu item
- Default Nav Highlight
- Different methods of adding menu support to custom theme
- Multiple navigation menu in same location
- How to register a menu based on a ACF condition
- current_page_item is missing inside wp_nav_menu
- search form leads to 404
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- Add Login and logout buttons to top menu bar
- How to change a specific admin label
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Bizarre Child Menu Issue on WP Site
- Header menu aligned right on all pages except for single-post page [closed]
- Combine multiple menus using the filter wp_nav_menu_items
- Menu and category highlighting for a single post
- WordPress Toggle Menu has stopped working
- How to add publish/draft button in Admin Post Lists
- Which method is more correct for removing WooCommerce Extensions menu item?
- Product categories are mixed when creating menu
- How to add widget in main menu
- how to create pages and link them to a menu
- Beyond widget side menu editing, with the php page, custom template
- Insert menu into theme location depending on user logged in/out status
- How to sort a sub-menu, generated with get_pages(), by the page order instead of alphabetically?
- How I can add div to menu?
- Hide certain post types from editors
- Adding custom field in menu options [duplicate]
- wp_nav_walker that interacts with widgets to setup mega menu
- add_role menu pages are not visible
- Adding a filter with custom function to the menu / navigation
- How to add a class name to the ancestor of a post?
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Call wordpress function through functions.php when pressing menu
- How to add more than one menu for logged in members?