WordPress Admin Bar, also known as the WordPress Toolbar is an extremely useful navigation feature of a WordPress website. It allows navigating to different parts of your website, creating a post, providing your profile details, and a lot more. But it can also be a clutter to the UI. If you do not want it to display on the frontend of your website, you can just disable it. Disable the WordPress toolbar from appearing on the front end of your website using the following code.
Where to place? functions.php.
- To provide users a better experience without the top bar that floats around all the time.
- If you have a separate menu that has the same functionalities WordPress provides on the admin bar.
- If you are using a static HTML caching system and you want to prevent it caching the user information from the logged-in users (especially while using limited plans such as the Cloudflare free plan.)
// Remove WordPress admin bar from the front end add_filter( 'show_admin_bar', '__return_false' );
Note that the admin URL will still be visible on the backend. Only those who access the website from the frontend will see the changes. You can still disable the admin bar in the backend if you really want to. However, it is not recommended to do so. If it is just the visual things that are ignorable, we suggest you leave it as it is and don’t mess with it. If you still need to disable the admin bar in the backend as well. There are several ways to do that.
- A PHP comment. Can be removed or changed.
- We simply set the
show_admin_barfunction using the
add_filterhook to return false so that the code will not be executed on the frontend.