How to fix the WordPress Admin Bar showing when logged out

You've just logged out of WordPress, but the admin bar is still showing. I'll show you how to resolve the problem in 2 minutes.

So, you have just logged out of your WordPress dashboard, but to your surprise, the admin bar is still there. You log in, and out again, but the admin bar is still there. First of all, don’t panic. There is a simple explanation.

Let me calm your fears:

  • Your admin area is safe - The public cannot access it. All they see is the bar itself, but none of the links on it will work.
  • It’s easy to fix - In just two minutes I will help you solve your problem. I promise.

I am aware of two different culprits; W3 Total Cache, and CloudFlare full page cache.

W3 Total Cache Page Cache

WordPress by default will query a database and run PHP every time a page is requested. In essence, it builds the page every time a visitor lands on it.

W3 Total Cache takes that finished version of the page, and stores the final output of the page in the cache. Then when a subsequent visitor lands on the page, the page is loaded from the cache, rather than built on demand.

This significantly speeds up the render time of your webpage as well as reducing the load on the web server, and I would highly recommend adding caching to your website. You can view our guide on how to set up W3 Total Cache properly here, or follow this more up-to-date version that is specific to A2 Hosting.

The problem you face is because you have misconfigured W3 Total Cache. You have set it to cache pages for logged in users. By doing this, you are caching the entire page, including the admin bar.

When logged out, you are only seeing a cached version of the Admin Bar. Because a user is not logged in, they will get an authentication error when they try to visit any of the admin area links. Your site is, and always has been safe from this issue.

Fixing the problem in W3 Total Cache

The solution is straightforward. Let me show you.

How to fix the WordPress admin bar from being shown when logged out by W3 Total Cache.

CloudFlare Page Cache

If you configure a rule in CloudFlare to cache the entire HTML page, and then visit your WordPress site while logged in, that page will be cached in its entirety by CloudFlare. This includes any admin bar.

You can easily test that this is the problem, by clearing the CloudFlare cache and visiting the page while logged out. You may need to clear the browser cache by pressing [CTRL] [F5]. If the admin bar disappears, the problem is caused by CloudFlare.

Fixing the problem caused by CloudFlare

While this solution is specifically geared towards CloudFlare users, it will also fix the problem caused by any other caching plugin or caching service, including W3 Total Cache.

How to fix the WordPress admin bar from being shown when logged out with CloudFlare Page Cache.
Jonathan Griffin. Editor @ The Webmaster

About the author

Editor, Hosting Expert, SEO Developer, & SEO Consultant.

Jonathan is currently the Editor & CEO at The Webmaster. He is also an SEO Developer offering consultancy services, primarily to other web development companies. He specializes in the technical side of SEO, including site audits, development of SEO related features, and site structure & strategy.

In his spare time, Jonathan has a passion for learning. He regularly undertakes professional courses on subjects ranging from python, web development, digital marketing, and Advanced Google Analytics.

Read more about Jonathan Griffin on our About Page.