In this guide, we will cover how to display a user’s name in a WordPress menu. This will require a bit of knowledge with working with code snippets and general shortcodes in WordPress.

This solution will create a custom shortcode or variable, {{username}} to be inserted in any WordPress menu and then replace this variable with the user’s actual display name. This is great if you want to create a meta menu that points to a user’s profile page of some sort that says “Welcome admin“.

Example of Welcome {{username}}, on frontend of a WordPress site.

To add a custom code snippet to our WordPress site, without worrying about losing functionality in WordPress you may follow this guide.

Once the code snippet is added, it will replace the variable {{username}} with the user’s display name. To add this variable to your WordPress menu please take the following steps:

  1. Login to your WordPress dashboard.
  2. Navigate to Appearance and select Menus.
  3. Choose your menu you would like to add the username to.
  4. Find or add a menu item you would like to show the username in and click on the dropdown arrow.
  5. Edit the Link Text and add {{username}}
  6. Save your menu.
  7. Repeat this for each menu you would like to show the username in.
Example how to add {{username}} to WordPress menu.
Example how to add {{username}} to WordPress menu.

If you have any questions or feedback regarding this code snippet, please don’t hesitate to leave a comment below.

Photo by Adam Solomon on Unsplash | Code reference taken from (and altered): https://wordpress.stackexchange.com/questions/196453/displaying-logged-in-user-name-in-wordpress-menu