Overide WordPress things

This is nothing very exciting, and can be found all over the net, but thought I’d share a few code tweaks to hide or modify the WordPress Dashboard. Handy if you want to clean up and hide things for your users or clients.

First removes the default Dashboard Widgets. I’ll post how to add your own custom Widgets in a later post.
Just add the following code to your themes functions.php file, it works for both parent and child themes. Obviously you can choose to leave some out if you want to show some widgets.

// remove dashboard widgets
function remove_dashboard_meta() {
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
}
add_action( 'admin_init', 'remove_dashboard_meta' );

This will remove all Dashboard Widgets, you can choose to show/remove some or all of them if you wish, just comment out the remove_meta_box line that corresponds to the Widget you want to show.


Second hides the built in Help Menu from all Users except Admins. This is useful if you want to add your own help files, which I’ll explain in a later post.
Again, add the code to your themes functions.php file, and also works with parent and child themes.

// remove default help tab
add_filter( 'contextual_help', 'mycontext_remove_help', 999, 3 );
 function mycontext_remove_help($old_help, $screen_id, $screen){
 $screen->remove_help_tabs();
 return $old_help;
}

Lastly, how to change the silly “Howdy” message in the Dashboard. A lot of my clients ask about this and thankfully there is a simple way to change it.
Just add to your themes functions.php file, again works with parent and child themes.

// change the stupid Howdy message
function replace_howdy( $wp_admin_bar ) {
 $my_account=$wp_admin_bar->get_node('my-account');
 $newtitle = str_replace( 'Howdy,', 'Hello,', $my_account->title );
 $wp_admin_bar->add_node( array(
 'id' => 'my-account',
 'title' => $newtitle,
 ) );
 }
 add_filter( 'admin_bar_menu', 'replace_howdy',25 );

If you want to completely remove “Howdy”, just remove “Hello” like this $newtitle = str_replace( 'Howdy,', '', $my_account->title );.

More code fun can be found in the WordPress Code Reference.