Skip to:
Content
Pages
Categories
Search
Top
Bottom

Login/Logout Top Menu Only


  • goviajero
    Participant

    @goviajero

    Hello, I’m using this function from bbpress codex to add login/logout to the menu.

    I want to show the login/logout on the top menu only, not on the header. Any way to do this? Hope its just a simple tweak. Thanks

    add_filter( ‘wp_nav_menu_items’, ‘rkk_add_auth_links’, 10 , 2 );
    function rkk_add_auth_links( $items, $args ) {
    if ( is_user_logged_in() ) {
    $items

    _______________________________________________________________________________________

Viewing 1 replies (of 1 total)

  • Robin W
    Moderator

    @robin-w

    depends what you mean by top menu, I suspect primary, in which case

    add_filter( 'wp_nav_menu_items', 'rkk_add_auth_links', 10 , 2 );
    function rkk_add_auth_links( $items, $args ) {
    if (is_user_logged_in() && $args->theme_location == 'primary') {
     $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
     }
     elseif ( !is_user_logged_in() ) {
     $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
     $items .= '<li><a href="'. site_url('wp-login.php?action=register') .'">Register</a></li>';
     $items .= '<li><a href="'. site_url('wp-login.php?action=lostpassword') .'">Lost Password</a></li>';
     }
     return $items;
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar