WordPress Hide Top Toolbar

In order to facilitate administrators to quickly enter the backend from the frontend to manage the website, WordPress has forced a toolbar on the top of WordPress, and it is displayed to all users by default, which is sometimes annoying. So how to remove this annoying toolbar?

By default, WordPress displays a login page at the top of the front-end..

By default, only logged-in users can see the top toolbar, and non-logged-in users cannot see it. With the existence of this toolbar, we can easily enter the backend from the website frontend. For example, when we see an article that needs to be modified, we can directly click Edit Article to enter the backend article modification page.

Disable the toolbar completely

In order to facilitate administrators to quickly enter the backend from the frontend to manage the website, WordPress has forced a toolbar on the top of WordPress, and it is displayed to all users by default, which is sometimes annoying. So how to remove this annoying toolbar?

1. Completely remove the WordPress toolbar (code 1)

show_admin_bar(false);

2. Completely remove the WordPress toolbar (code 2)

add_filter('show_admin_bar', '__return_false');

Show toolbar only to certain users

1. Only visible to administrators

if (!current_user_can('manage_options')) { add_filter('show_admin_bar', '__return_false'); }

2. Only visible to administrators and editors

if (!current_user_can('edit_posts')) { add_filter('show_admin_bar', '__return_false'); }

Move the toolbar from the top to the footer

function fb_move_admin_bar() { echo ' '; } // If you want the toolbar to be displayed at the top of the background, please delete this line of code add_action( 'admin_head' , 'fb_move_admin_bar' ); // If you want the toolbar to be displayed at the top of the foreground, please delete this line of code add_action( 'wp_head' , 'fb_move_admin_bar' );

The above codes can be added to functions.php.

It is recommended to use the Snippets plugin to add code to functions.php without modifying the functions.php file.

score

Leave a Reply

Your email address will not be published. Required fields are marked *