Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #973435

    Hello, I’m wondering if this will work in the main nav menu?
    https://kriesi.at/support/topic/submenu-adding-dropdownhover-loginlogout-widgetbuttons/

    Thank you!

    #973513

    Hey soundstrat,
    Please try adding this code to the end of your functions.php file in Appearance > Editor, and changing the links to match your site:

    
    add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
    function add_loginout_link( $items, $args ) {
        if (is_user_logged_in() && $args->theme_location == 'avia') {
            $items .= '<li><a href="http://127.0.0.1/wp-login.php?action=logout">Log Out</a></li>';
        }
        elseif (!is_user_logged_in() && $args->theme_location == 'avia') {
            $items .= '<li><a href="http://127.0.0.1/wp-login.php">Log In</a></li>';
        }
        return $items;
    }

    Best regards,
    Mike

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.