How to Hide Admin Bar from the Front-End in WordPress (Two Ways)

The default setting of WordPress shows an admin bar on the front-end. It will show up when you view your content (be it pages or posts) in the logged in status. You can make certain actions from the admin bar, depending on your user role. While the feature offers quick access over a certain action (e.g., content editing), you might find it annoying instead. You can change the default setting to hide the admin bar from the front-end in WordPress. There are several ways to do so.

In this post, we will show you two ways to hide the admin bar from the front-end.

Option 1: Hiding the Admin Bar for Your Own User Profile

Every user on a WordPress website has access to the user setting whereby they can set things like nickname, profile picture, password, and so on. To do these, you can go to Users -> Profile on the WordPress dashboard. From here (Profile screen), you can also show/hide the admin bar from the front-end.

To hide the admin bar from the front-end, you can simply uncheck the Show Toolbar when viewing site option.

Don’t forget to click the Update Profile button at the bottom to apply the change.

Option 2: Hiding the Admin Bar for All Users (Except Admin)

The option above will only hide the admin bar for your own user profile. If you have a WordPress website with multiple users and want to hide the admin bar from the front-end for all users (except the administrator), you can add a new function to your theme.

First, login to your WordPress dashboard with your admin user and go to Appearance -> Theme Editor. Select (click) the functions.php file on the right panel to edit it.

Add the following code snipped right after the last line of the functions.php file content. Click the Update File button to update the file.

The snipped.

add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}

After adding the snippet above, all users on your website — except ones with an admin role — will no longer see the admin bar when they view your website.

A little note: If you have never edited the functions.php file before, it’s strongly recommended to back up the file before you edit it. If everything is not going the way you expected, you can simply restore the original file.

This page may contain affiliate links, which help support utilizeWP.

Boost your site speed with the best caching plugin in the world

Leave a Reply

Share This