Skip to content

How To Remove WordPress Admin Bar

Most of WordPress users don’t want to see the WordPress admin bar on the front-end of the website for obvious reasons. There are a lot of codes around the internet to remove WordPress admin bar from the front-end of the website, but they just disable the admin bar and leave the blank space of the bar on the website.

I got a code which will remove the admin bar and the CSS codes of the admin bar completely from the frond-end of the website

Just add following code to your theme’s functions.php file to remove the admin bar:

// Disable Admin Bar
if (!function_exists('df_disable_admin_bar')) {

    function df_disable_admin_bar() {

        // for the admin page
        remove_action('admin_footer', 'wp_admin_bar_render', 1000);
        // for the front-end
        remove_action('wp_footer', 'wp_admin_bar_render', 1000);

        // css override for the admin page
        function remove_admin_bar_style_backend() {
            echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';

        // css override for the frontend
        function remove_admin_bar_style_frontend() {
            echo '<style type="text/css" media="screen">
            html { margin-top: 0px !important; }
            * html body { margin-top: 0px !important; }
        add_filter('wp_head','remove_admin_bar_style_frontend', 99);

1 thought on “How To Remove WordPress Admin Bar”

  1. Thankyou very much Hardeep for posting this code it works perfectly as of August 14th. I will be linking to your page from my blog blog when I get around to writing a new post and updating an article I have about this very thing.

Leave a Reply

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