The WordPress admin bar is a toolbar that appears at the top of the website for logged-in users. It provides quick access to various administrative functions, such as editing posts, pages, menus, widgets, plugins, themes, etc. The WordPress admin bar can be useful for website owners and developers who need to manage their website easily and efficiently. However, the WordPress admin bar can also be annoying or distracting for some users who do not need or want to see it. For example, some users may prefer a cleaner and more minimalist look for their website, or some users may want to hide the WordPress admin bar from certain user roles or visitors. Therefore, it is possible to hide the WordPress admin bar using a plugin or code.

Using a plugin:

A plugin is a software component that adds specific features or functions to an existing application. There are various plugins available for WordPress that can help users hide the WordPress admin bar. For example, some of the popular plugins are:

  • Admin Bar Disabler: This plugin allows users to disable the WordPress admin bar completely or selectively for different user roles or capabilities.
  • Hide Admin Bar from Non-Admins: This plugin allows users to hide the WordPress admin bar from all users except administrators.
  • WP Admin UI Customize: This plugin allows users to customize the appearance and functionality of the WordPress admin bar, such as changing the color, icon, position, menu items, etc.

To hide the WordPress admin bar using a plugin, users need to follow these steps:

  • Install and activate the plugin of their choice from the WordPress dashboard or the plugin directory
  • Go to the plugin settings page and configure the options according to their preferences
  • Save the changes and check the website to see if the WordPress admin bar is hidden

Using code:

Code is a set of instructions that tells a computer how to perform a specific task. Users can also hide the WordPress admin bar by adding some code snippets to their website files. There are two ways to add code snippets to a WordPress website: using the functions.php file or using a custom plugin.

The functions.php file is a file that contains PHP code that affects the behavior and functionality of a WordPress theme. Users can add code snippets to their functions.php file to hide the WordPress admin bar globally or conditionally. For example, some of the code snippets are:

  • To hide the WordPress admin bar globally for all users, add this code snippet to the functions.php file:
add_filter('show_admin_bar', '__return_false');
  • To hide the WordPress admin bar conditionally for specific user roles, add this code snippet to the functions.php file:
function hide_admin_bar($show) {
  if (!current_user_can('administrator')) { // change 'administrator' to any user role
    return false;
  }
  return $show;
}
add_filter('show_admin_bar', 'hide_admin_bar');

A custom plugin is a plugin that users create themselves by writing PHP code and saving it as a .php file in the wp-content/plugins folder of their website. Users can create a custom plugin to hide the WordPress admin bar globally or conditionally. For example, some of the code snippets are:

  • To hide the WordPress admin bar globally for all users, create a .php file with this code snippet and save it in the wp-content/plugins folder:
<?php
/*
Plugin Name: Hide Admin Bar
Description: A custom plugin to hide the WordPress admin bar
*/

add_filter('show_admin_bar', '__return_false');
  • To hide the WordPress admin bar conditionally for specific user roles, create a .php file with this code snippet and save it in the wp-content/plugins folder:
<?php
/*
Plugin Name: Hide Admin Bar
Description: A custom plugin to hide the WordPress admin bar
*/

function hide_admin_bar($show) {
  if (!current_user_can('administrator')) { // change 'administrator' to any user role
    return false;
  }
  return $show;
}
add_filter('show_admin_bar', 'hide_admin_bar');

To hide the WordPress admin bar using code, users need to follow these steps:

  • Choose whether to use the functions.php file or a custom plugin
  • Add the code snippet of their choice to the file
  • Save and upload the file to their website
  • Check the website to see if the WordPress admin bar is hidden

Conclusion

Hiding the WordPress admin bar is a simple and effective way to improve the appearance and user experience of a website. Users can hide the WordPress admin bar using a plugin or code, depending on their needs and preferences. Using a plugin is easier and faster, but may require a premium or paid version to access some features or functions. Using code is more flexible and customizable, but may require some technical skills and coding knowledge. Hiding the WordPress admin bar can help users create a cleaner and more minimalist look for their website, or hide the WordPress admin bar from certain user roles or visitors.

Categorized in:

Tagged in:

, , , ,