Changing Howdy Text In WordPress Admin Tool Bar

You can change you the Howdy text in you WP admin tool bar which appears after logging in to your WordPress site.
This is easy, open your theme’s function.php file and add the following code replacing welcome  with the text you want to display in Howdy:

add_action( ‘admin_bar_menu’, ‘wp_admin_bar_my_custom_account_menu’, 11 );

function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );

if ( 0 != $user_id ) {
/* Add the “My Account” menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __(‘Welcome, %1$s’), $current_user->display_name );
$class = empty( $avatar ) ? ” : ‘with-avatar’;

$wp_admin_bar->add_menu( array(
‘id’ => ‘my-account’,
‘parent’ => ‘top-secondary’,
‘title’ => $howdy . $avatar,
‘href’ => $profile_url,
‘meta’ => array(
‘class’ => $class,
),
) );

}
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.