Hi,
I would like to add a logout link to one of my drop-down menus in the main menu. I know the code to add a logout link as a top menu item:
function add_primary_logout_link($items, $args)
{
if(is_user_logged_in() && $args->theme_location == ‘avia’)
{
$newitems = $items;
$newitems .= ‘<li class = “menu-item custom-menu-item”>‘.__(‘Log Out’,’avia_framework’).’‘;
}
else{
$newitems = $items;
}
return $newitems;
}
add_filter(‘wp_nav_menu_items’, ‘add_primary_logout_link’, 5, 2);
Unfortunately, I’m not sure how to add this link to a child menu instead of at the top level. I’m adding a log in and more detailed commentary in the private content.
Hey eqira!
I’m guessing you would have to edit the menu walker but it would have to be considered custom work as it would take a lot of time and code to implement. It would be best to hire a freelancer to help you out with this customization.
Regards,
Elliott
Ok thanks. I will just leave it as a separate top level menu item. One more question though… all of the other top level links in the menu have a color bar underneath them that lights up when they are selected. How do I get my logout link to do this as well? I assume it has something to do with .avia-menu-fx and .avia-arrow. Thanks.
Never mind, I figured it out myself. For anyone else interested, I merely changed the line:
$newitems .= ‘<li class = “menu-item custom-menu-item”>‘.__(‘Log Out’,’avia_framework’).’‘;
to:
$newitems .= ‘<li class = “menu-item custom-menu-item”>‘.__(‘Log Out’,’avia_framework’).'<span class=”avia-bullet”></span><span class=”avia-menu-fx”><span class=”avia-arrow-wrap”><span class=”avia-arrow”></span></span></span>‘;