Logged in and there’s a strip of empty space at the top of your website? That’s WordPress making room for the admin bar: it pushes your whole page down by 32 pixels (46 pixels on phones and small tablets).
Your visitors never see this gap, only logged-in users who see the admin bar. Still, it can make your header look off while you work on the site. Here are three ways to get rid of it.
Don’t have the plugin yet? Download Better Admin Bar for free from WordPress.org.
Option 1: Remove the gap, keep the admin bar
- Install and activate Better Admin Bar (Plugins → Add New Plugin, search for “Better Admin Bar”).
- Go to Settings → Better Admin Bar and open the Admin Bar tab.
- Under Display Settings, turn on Remove the admin bar gap.
- Click Save Changes.
Your page now starts at the very top again and the admin bar lies on top of it. Keep in mind that it covers the top 32 pixels of your header.
Option 2: Remove the gap and auto-hide the admin bar
The cleanest result: turn on Remove the admin bar gap together with Auto-hide the admin bar. Your website looks exactly like your visitors see it, and the admin bar slides over the page when you move the mouse to the top. See how to auto-hide the admin bar.
Option 3: Remove the gap with code
This tells WordPress not to push the page down. Add it to your child theme’s functions.php or to a code snippets plugin.
add_action( 'after_setup_theme', function () {
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
} );
Like Option 1, the admin bar then covers the top of your page.
Don’t need the admin bar at all?
When the admin bar is removed for a user role, the gap goes with it. See how to hide the admin bar in WordPress.
The gap is still there?
- Your theme adds its own space: some themes add extra padding for the admin bar, for example to a sticky header. Check your theme’s header settings.
- Caching: clear the cache of your caching plugin and reload the page.
