If you constantly use the WordPress admin panel, you must have noticed the 'Howdy Admin' text on the screen's top right corner. Because of the fixed position toolbar, this text is always visible everywhere you go. In this helpful tutorial for the developers who embrace the attention to detail, I'm going to show how you can modify or remove this text from the WP panel with a WP filter hook, so you are not forced to read it any time you log in.
Not every WordPress administrator has noticed the ugly text on the top right corner of the WP admin panel, even if it’s an odd text and has a fixed position on the screen.
I guess this text does not bother everybody, but I have a solution for those who do not like this way of WordPress greeting admins.
Change the WordPress ‘Howdy Admin’ text to what you desire
A filter hook in WordPress can modify the admin bar menu.
The admin_bar_menu
filter hook has the ability to modify or remove items in the admin panel bar of WordPress.
Use this code in your functions.php
of your active theme or your custom-made plugin:
add_filter('admin_bar_menu', 'change_howdy_in_toolbar', 20);
function change_howdy_in_toolbar($wp_admin_bar){
//set your desired text to replace
$replaceWithThis = "Hi Admin";
//we need to modify my-account node in the toolbar
//'id' key is flag for replace action
$node = array(
'id' => 'my-account',
'title' => $replaceWithThis
);
//add_node will REPLACE the title
$wp_admin_bar->add_node($node);
}
As you see in the comments above, we need to modify the my-account node in the toolbar.
If you are already familiar with WordPress filters, you know a filter gives you a variable to use when you are modifying WP core content.
This parameter in the admin_bar_menu
filter is an instance of class WP_Admin_Bar
that contains useful methods to add or modify content. we named it $wp_admin_bar
like WP core function.
add_node()
method available in $wp_admin_bar
can add or modify a node in admin toolbar.
Two useful methods available by this variable are add_node
which can add or modify a node, and remove_node
, used in deletion.
add_node()
method accepts an array of information to add as new node or modifies an existing node if the id key is used before.
Remove the ‘Howdy Admin’ from the WordPress admin bar completely
To remove the box and the text together from the admin bar, you can use this code in your functions.php
of your active theme or your custom-made plugin:
add_filter('admin_bar_menu', 'remove_howdy_from_toolbar', 20);
function remove_howdy_from_toolbar($wp_admin_bar){
$wp_admin_bar->remove_node('my-account');
}
written by Mehdi Nazari about in WordPress WordPress Admin Panel WordPress Plugin Development
What do you think about "How to Change or Remove ‘Howdy Admin’ in WordPress Toolbar"?