Please see the below 2 scripts to remove the howdy in Wordpress, you can use any 1:
Solution 1:
add_filter( 'admin_bar_menu', 'replace_wordpress_howdy', PHP_INT_MAX - 100);
function replace_wordpress_howdy( $wp_admin_bar ) {
$my_account = $wp_admin_bar->get_node('my-account');
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => substr($my_account->title, strpos($my_account->title, '<span class="display-name">')),
));
}
Solution 2:
function pac_da_custom_admin_bar_user_name() {
global $wp_admin_bar;
// Define the ID of the node representing the "My Account" section in the admin bar.
$node_id = 'my-account';
// Check if the specified node exists in the admin bar.
if ($wp_admin_bar->get_node($node_id)) {
// Get the current title of the "My Account" section.
$current_title = $wp_admin_bar->get_node($node_id)->title;
// Split the current title into an array based on the comma and space separator.
$newTitle = explode(", ", $current_title);
// Update the "My Account" section title with the second part of the split title if available,
// otherwise keep the current title.
$wp_admin_bar->add_node(array(
'id' => $node_id,
'title' => isset($newTitle) && isset($newTitle[1]) ? $newTitle[1] : $current_title,
));
}
}
// Hook the custom admin bar user name function to run before the admin bar is rendered.
add_action('wp_before_admin_bar_render', 'pac_da_custom_admin_bar_user_name');
This topic was modified 7 months ago by
ankitbnl406