How to Disable The WP Admin Bar in WordPress

To hide the WordPress Admin Bar for all users on the frontend of your site, you can add a simple code snippet to your theme’s functions.php file or create a custom plugin. Here are the steps for both methods:

Method 1: Add Code to functions.php

  1. Open your theme’s functions.php file (located in wp-content/themes/your-theme/).
  2. Add the following code to hide the admin bar on the frontend for all users:

// Hide the admin bar on the frontend for all users
add_filter('show_admin_bar', '__return_false');

Method 2: Create a Custom Plugin

  1. Create a new file in your wp-content/plugins/ directory, for example, hide-admin-bar.php.
  2. Add the following code to the file:

<?php
/*
Plugin Name: Hide Admin Bar
Description: Hides the WordPress Admin Bar on the frontend for all users.
Version: 1.0
Author: Your Name
*/

// Hide the admin bar on the frontend for all users
add_filter('show_admin_bar', '__return_false');

Additional Option: Use CSS (Optional)

You can also hide the admin bar using CSS, but this method is not as robust as the PHP method since the admin bar will still load but be hidden from view.

  1. Open your theme’s style.css file (located in wp-content/themes/your-theme/).
  2. Add the following CSS to hide the admin bar:

/* Hide the admin bar */
#wpadminbar {
    display: none;
}

By following either of the PHP methods, you will effectively hide the WordPress Admin Bar for all users on the frontend of your site.

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.