Skip to content

Instantly share code, notes, and snippets.

@knolaust
Last active January 30, 2024 14:47
Show Gist options
  • Save knolaust/fe6abf60988fe532d31e0f4c17fd5cf3 to your computer and use it in GitHub Desktop.
Save knolaust/fe6abf60988fe532d31e0f4c17fd5cf3 to your computer and use it in GitHub Desktop.
Change "Howdy Admin" in Admin Bar
<?php
/**
* Customizes the WordPress admin bar greeting text.
*
* This function replaces the default "Howdy," text in the WordPress admin bar with a custom greeting text.
*
* Usage:
* - Edit the value of the `$new_howdy` variable to set the desired greeting text.
*
* @param WP_Admin_Bar $wp_admin_bar The WordPress admin bar object.
*
* Gist Keywords: wordpress, customization, admin
*
* @category WordPress
* @author Knol Aust
* @version 1.0.0
*/
function knolaust_replace_howdy( $wp_admin_bar ) {
// Edit the line below to set what you want the admin bar to display instead of "Howdy,".
$new_howdy = 'Welcome,';
$my_account = $wp_admin_bar->get_node( 'my-account' );
$wp_admin_bar->add_node(
array(
'id' => 'my-account',
'title' => str_replace( 'Howdy,', $new_howdy, $my_account->title ),
)
);
}
add_filter( 'admin_bar_menu', 'knolaust_replace_howdy', 25 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment