Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save endurtech/d3eff716f4c142e4b5eb4e6cbbe3eccc to your computer and use it in GitHub Desktop.
Save endurtech/d3eff716f4c142e4b5eb4e6cbbe3eccc to your computer and use it in GitHub Desktop.
<?php
// Replace WordPress Admin Bar Welcome Message with Custom Text
// Replaces the default 'Howdy' welcome text at the top right next to the logged in username with text of your own choosing.
// https://endurtech.com/replace-wordpress-admin-bar-welcome-text-howdy/
add_action( 'wp_before_admin_bar_render', 'replace_howdy_text' );
function replace_howdy_text()
{
global $wp_admin_bar;
$my_account = $wp_admin_bar->get_node( 'my-account' );
if ( ! $my_account || ! isset( $my_account->title ) )
{
return;
}
$welcome_text = 'Hello,'; // Replace Hello with your custom Welcome text message.
$new_title = str_replace( 'Howdy,', $welcome_text, $my_account->title );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $new_title,
) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment