• Resolved johnwiggity

    (@johnwiggity)


    Hi I’m using this code to display the username in the top nav of my 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 == ‘secondary-menu’) {
    $user=wp_get_current_user();
    $name=$user->display_name; // or user_login , user_firstname, user_lastname
    $items .= ‘<li style=”color: #FFF;”>Hi, ‘.$name.”;
    }
    return $items;

    }

    What I want to do is link the

    Hi, ‘.$name.”

    to the users account page. How would I go about doing that? Tried a simple hyperlink but didn’t seem to work.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to Link Display Name’ is closed to new replies.