Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Login-/Logout link only in main menu

Home / Forums / Pinnacle Theme / Login-/Logout link only in main menu

This topic is: Resolved
[Resolved]
Posted in: Pinnacle Theme
July 14, 2016 at 11:02 am

Hello,

I added a code-snipped to get a Login-/Logout-link in the menu. Together with the SimpleModal-plugin I get a modal login form, where you can login/logout and it redirects you to the current page.
Here is the code:

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);

function add_login_logout_link($items, $args) {
$pageURL = 'http://';
$pageURL .= $_SERVER['HTTP_HOST'];
$pageURL .= $_SERVER['REQUEST_URI'];

/** if( !($args->theme_location == 'nav-main') )
return $items;

global $pinnacle;
*/
ob_start();
wp_loginout($pageURL);
$loginoutlink = ob_get_contents();
ob_end_clean();
$items .= '<li>'. $loginoutlink .'</li>';
return $items;
}

My problem is that the Login/Logout-link appears on every menu on the site. How can I specify to appear only on main menu? I tried it with the commented out part of the snippet, but it doesn´t work.

Thanks…
Dirk

  • The forum ‘Pinnacle Theme’ is closed to new topics and replies.