WordPress Development
How to Change WordPress admin bar Greeting Howdy text
If your using wordpress CMS, you must seen a common greeting “Howdy” in wp admin bar. In this tune I am going to describe how change or remove the greeting “Howdy” text. Ok let’s start, “How to Change WordPress admin bar Greeting Howdy text”.
Taking below code in your wordpress theme functions.php file.
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, ), ) ); } }
After take the function you see your Howdy text change in to “Welcome”. If want to the welcome text you can easily change welcome from above function from your theme functions.php file.
If want fully remove the Howdy text use below function in your theme functions.php file instead of first function.
//Remove Howdy Text add_filter('admin_bar_menu','change_howdy_text_toolbar'); function change_howdy_text_toolbar($wp_admin_bar) { $getgreetings = $wp_admin_bar->get_node('my-account'); $rpctitle = str_replace('Howdy,','',$getgreetings->title); $wp_admin_bar->add_node(array("id"=>"my-account","title"=>$rpctitle)); }
By using the two function everyone can easily handle the text. You can using the function to make wordpress plugin to change wordpress admin bar greeting Howdy text. If face any problem comment here.
Comments are closed