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
- Open your theme’s functions.php file (located in wp-content/themes/your-theme/).
- 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
- Create a new file in your wp-content/plugins/ directory, for example, hide-admin-bar.php.
- 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.
- Open your theme’s style.css file (located in wp-content/themes/your-theme/).
- 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.