Hide admin bar in WordPress
To hide the WordPress admin bar for all users except administrators, you can add some code to your theme’s functions.php
file or create a custom plugin. Here’s how you can do it:
- Using the functions.php File:
- Access your WordPress site’s files via FTP or the file manager in your hosting control panel.
- Locate the
functions.php
file in your active theme’s folder (usually found inwp-content/themes/your-theme-name/
). - Add the following code at the end of the
functions.php
file:
add_action('after_setup_theme', 'hide_admin_bar');
function hide_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
- Save the changes and upload the modified
functions.php
file back to your server.
2. Using a Custom Plugin:
- Navigate to the WordPress admin area and go to “Plugins” > “Add New”.
- Click on “Upload Plugin” and select the plugin file (a PHP file with a plugin header) that contains the following code:
<?php
/*
Plugin Name: Hide Admin Bar Except for Administrators
Description: Hides the WordPress admin bar for all users except administrators.
Version: 1.0
Author: Your Name
*/
add_action('after_setup_theme', 'hide_admin_bar');
function hide_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
- Activate the plugin.
After implementing either of these methods, the WordPress admin bar should be hidden for all users except administrators.
Download WordPress from here : click
74 Views
1 thought on “How to hide admin bar except administration in wordpress”