WordPress Shortcode in Menu Item Title

First of all download ‘Shortcodes in Menus’ plugin and install/activate it.

Then in theme’s function.php add following code.

add_shortcode( 'current-username' , 'ss_get_current_username' );
function ss_get_current_username(){
    $user = wp_get_current_user();
    return $user->display_name;
} 

Now, in menu’s navigation lable write [current-username] shortcode.

Same thing you can do for displaying avatar.

This way it will display logged in user name in menu item.

Leave a Comment