Rename WordPress Admin Bar Menus and Change Howdy Text

Since I changed the Title of this blog, the Admin Bar was acting a little wired. The new title is a bit long, and it was pushing the Admin Bar menu items next to the blog title menu item down making it twice the standard height of 28 pixels. It was okay with me as I selected to display the Admin bar only at backend. There must be some CSS issues, but I choose to rename the menu instead. Here is how you rename WordPress Admin Bar menu items using the wp_before_admin_bar_render hook.

All you need to know is the ID of the menu item you are going to rename. You can do so by either going to the source code of the Admin Bar menu. Look for the list item <li> ID and remove the ‘wp-admin-bar-‘ part. For example, if you are going to rename the “New” menu item’s title, find the list item ID of the item (which is wp-admin-bar-new-content) and remove the “wp-admin-bar-” part.

Rename WordPress Admin Bar Menu Items

function custom_adminbar_titles() {
	global $wp_admin_bar;
        $wp_admin_bar->add_menu( array(
                'id'    => 'site-name',
                'title' => 'ItsAbhikDotCom',
			) 
		);
}
add_action( 'wp_before_admin_bar_render', 'custom_adminbar_titles' );

Change the “Howdy” Text in WordPress Admin Bar

The process to change the “howdy” text in admin bar is almost as same as rename WordPress admin bar menu items. Normally it shows the “Howdy, Username” with the Gravatar of the user. Since it’s contains a text, username and avatar, the process needs a little tweak to go through. Here is the sample function that replaces the “Howdy” text to “Welcome Back,”. You can change it to whatever you like.

function custom_adminbar_welcome() {
	global $wp_admin_bar;

		$name = wp_get_current_user()->display_name;
		$avatar = get_avatar( wp_get_current_user()->ID, 28 );
		$class = $class = empty( $avatar ) ? '' : 'with-avatar';

		$wp_admin_bar->add_menu( array(
                'id'    => 'my-account',
                'title' => __('Welcome Back,  ') . $name . $avatar,
				'class' => $class
			) 
		);
}
add_action( 'wp_before_admin_bar_render', 'custom_adminbar_welcome' );

The trick here is to change the ‘my-account’ menu title with the custom text including the display name and the Gravatar of the current user. If you want to bold the display name, you have to use inline CSS as the default font-weight is set to 400. Replace the array value that outputs the title with this one.

__('Welcome Back,  ') . '<span style="font-weight:bold !important;">' . $name . '</span>' . $avatar,

rename wordpress admin bar menu

Now that you know how to rename WordPress admin bar menu titles (and, how top change that boring howdy text too), why don’t you thank me by sharing it in Facebook or Twitter?

Get Updates In Your Inbox

Get the WordPress Tips and latst Internet Marketing ideas delivered directly to your email inbox, plus access to our FREE Pro Blogging Model blogging guide.

You need to confirm your email once. Don't worry, we hate SPAMs as much as you do

Speak Your Mind

Your email address will not be published. Required fields are marked *

You may use these HTML Tags and Attributes

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>