WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've looked and have not found anything that works.

I am trying to include a shortcode in a menu item's 'Navigation Label'. Basically Iwould like to have a dynamic title displaying the user's name & avatar.

[profilepicture round] [user_name]

Right now it's just spit back out since Wordpress Menus do not parse shortcodes. I've tried:

function my_nav_menu_objects_shortcode_mangler($items) {
    foreach ($items as $item) {
       $item->title = do_shortcode($item->title);
    return $items;

But it doesn't parse it. I also tried $item->type_label with no luck. Am I just referencing the wrong attribute of item?

Also tried the following with no luck.

 add_filter('wp_nav_menu_items', 'do_shortcode');

The avatar and username can both be retrieved via php if needed:

<?php echo userpro_profile_data('user_login', $user_id); ?>
<?php echo userpro_profile_data('profilepicture', $user_id); ?>
share|improve this question
This could be theme specific if your theme uses a custom nav menu walker. Can you confirm whether it uses the default WP nav menu walker? – cfx Jul 6 '14 at 8:02
Also, what kind of menu item is it (link? page? post? other?) and where are you entering the shortcode (as the nav label? title? other?)? – cfx Jul 6 '14 at 8:09

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.