• Hi,

    Based on this tutorial Current author archive in navigation menu

    function my_nav_menu_author_link( $menu )
    {
        if( !is_user_logged_in() ){
    
            return $menu;
    
        } else {
    
            $link = get_author_posts_url( get_current_user_id() );
    
            $class = is_author() ? ' class="current-menu-item"' : '';
    
            $author_archive_link = 
            '<li' . $class . '>' .
                 '<a href="' . $link . '" >' .
                     __( 'My posts' ) .
                 '</a>' .
             '</li>';
    
            $menu = $menu . $author_archive_link;
    
            return $menu;
    
        }
    }
    
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_author_link' );

    i want to make navigation menus link for author archive and only show when logged in. It works perfectly. link to author archive show up on my blog menus. right corner.
    screenshot: screenshoot

    my question is, would it be possible to make that author menu to show up at Appearance – Menus dashboard? i just want to make that “author menu” become SUB Menu for another menu.

    thank you.

    thank you

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Current author archive in navigation menu’ is closed to new replies.