Wondering if anyone can help me on this:
I have the following:
/*
* -------------------------------
* custom_login_out_item_to_menu()
* -------------------------------
*/
add_filter('wp_nav_menu_items', 'custom_login_out_item_to_menu', 50, 2);
function custom_login_out_item_to_menu($items, $args) {
if (is_admin() || $args -> theme_location != 'top')
return $items;
$redirect = ( is_home()) ? false : get_permalink();
if (is_user_logged_in())
$link = '<a href="' . wp_logout_url($redirect) . '" title="' . __('Logout') . '">' . __('Logout') . '</a>';
else
$link = '<a href="' . wp_login_url($redirect) . '" title="' . __('Login') . '">' . __('Login') . '</a>';
return $items .= '<li id="log-in-out-link" class="menu-item menu-type-link">' . $link . '</li>';
}
I'm trying to add a custom login / logout link through my child theme functions.php. When I paste this into my functions.php, it's suppose to generate a login/logout link in my theme location : Top Navigation.
The problem is, it's now showing anything. Can anyone please help fix this?
Thanks,
Hal