Show / hide the WordPress Admin toolbar

During WordPress theme development, you might sometimes find the WordPress admin toolbar to be quite distracting. It’s in a fixed position at the top of the window and depending on your layout can cover some elements of the header. The bar adds space (margin) at the top of the page that might hide some of your sticky header content.

While still designing and developing your theme, you can hide the admin bar with this handy function. Include this in your functions.php:

show_admin_bar( false );

Be sure to comment this line out or set it to true once you deploy to a production environment. In addition, disabling the admin toolbar is explicitly forbidden according to the WordPress Theme Review Guidelines.

While we don’t cover it in this book, disabling the admin bar and other functions/functionality are best left up to plugins.