Lorenzo Sfienti

How to Hide WordPress Admin Bar Using Code Snippets

In the previous post I show you how to hide wordpress admin bar using plugins. In this article I show you how to hide wordpress admin bar using code. If you prefer to add custom code to your WordPress theme’s functions.php file, you can achieve the same result without relying on plugins. Here’s how you can hide the admin bar using code snippets:

  1. Access your theme’s functions.php file: Connect to your website using an FTP client or access the file manager in your hosting control panel. Locate the functions.php file within your active theme’s directory.
  2. Add the code snippet: Open the functions.php file and add the following code snippet at the bottom:
    // Hide admin bar for all users
    add_filter('show_admin_bar', '__return_false');
  3. Save the changes: Save the modified functions.php file, and the admin bar will be hidden for all users.