Hide the WordPress admin bar on the frontend for all users with this code snippet, saving you the hassle of manual disabling.
<?php
add_filter('show_admin_bar',function() {
return current_user_can('manage_options');
});
//Another version
add_filter( 'show_admin_bar', '__return_false' );
Quick Steps to Remove the WordPress Admin Bar on the Frontend
Follow these simple steps to remove the WordPress admin bar:
- Install and activate the WPCodeBox plugin, then navigate to WPCodeBox 2 in your WordPress dashboard.
- Copy the code snippet above and paste it into the WPCodeBox code editor.
- Give your snippet a descriptive title (like “Remove Admin Bar”), select PHP as the type, then click Save.
- Enable the snippet by toggling the switch to the active position.
- Test the changes by navigating to the frontend and verifying that the admin bar no longer appears.
That’s it! The WordPress admin bar is now disabled from your site’s frontend.
Remove WordPress Admin Bar – Additional Information
Why Remove the WordPress Admin Bar
The WordPress admin bar is a floating toolbar displayed at the top for logged-in users. It provides quick shortcuts to various admin pages and allows users to quickly switch between the frontend and the backend.
Removing the WordPress admin bar on the frontend comes with many benefits to improve the user experience and site management. The admin toolbar, while important, can create unnecessary distractions for all logged-in users.
When to Remove WordPress Admin Bar
Removing the admin bar completely is beneficial for sites such as:
- Client websites where users primarily interact with content rather than admin pages.
- Membership sites where users focus on content, not backend features.
- Educational websites where the toolbar might distract from learning materials.
- Portfolio sites where visual presentation is important.
- Staging or development sites where you want to simulate the live user experience.