How to Fix WordPress Admin Bar Showing When Logged Out

Team DiviFlash

Updated: December 26, 2024
Table of Contents

Don’t panic when you log out and still see the admin bar. This can happen due to reasons like:

  • Incorrect cache plugin settings
  • CDN caching issues
  • Custom code in functions.php file 

All of these issues come with simple solutions. In this article, we will show how to fix WordPress admin bar when logged out with step by step instructions.

Note: Although non-logged-in users may see the admin bar, they cannot access any of its links without valid login credentials.

1. Configure Cache Plugin’s Settings Properly

If you are using a caching plugin like W3 Total Cache, misconfigured cache settings can cause the admin bar to appear for logged-out users.

To ensure that your cache plugin is configured correctly, follow these steps:

  • Navigate to WordPress Dashboard > Performance > Page Cache
  • Check the box labeled “Don’t cache pages for following user roles
  • Click “Save Settings” and then clear the page caches to apply the changes.

Visit your website while logged out to verify if the admin bar is still visible. If it is still showing, it may be due to caching at the CDN level if you are using a Content Delivery Network.

2.  Clear CDN’s Caching

If you are using a Content Delivery Network (CDN), it may also be caching the admin bar for logged-out users. To resolve this, follow these steps:

  • Log in to your CDN provider’s control panel (e.g., CloudFlare).
  • Locate the caching settings or cache management section.
  • Find the option to purge or clear the cache for your website.
  • Click on the purge button to clear the cached content from your CDN’s servers.

After purging the cache, visit your website while logged out to see if the admin bar has disappeared or not. If not, then your site’s admin bar may be visible because of custom code.

3. Modify Custom Code in functions.php File

Custom code like add_filter(‘show_admin_bar’, ‘__return_true’); in the functions.php file can keep the admin bar visible. To fix this, you have to change the value from true to false.(If you don’t see this code, the problem might be elsewhere, not in your functions.php file.)

Here is how to do it:

  • Go to WordPress Dashboard > Appearance > Theme File Editor.
  • Open the functions.php file of your active theme.
  • Look for any custom PHP code that alters the visibility of the admin bar. Something like that:
  • add_filter(‘show_admin_bar’, ‘__return_true’);
  • Next, replace the “true” value with “false” and save changes.

Note: If all our provided solutions fail to fix your admin bar issue, reach out to a WordPress expert or your hosting provider.

How to Further Prevent Admin Bar Visibility While Logged Out

To prevent the admin bar from appearing to users who are logged out, you can follow these steps:

  • Avoid browsing your site while logged in. And instead try incognito or private browsing mode to see how the site appears to logged-out users.
  • Put your website in development mode while making major changes to your site. This temporarily disables caching, allowing you to view the latest version without interference.
  • Always remove or clear stored cached versions of your website after making any updates or changes.

Closing Thoughts

Now you know how to fix WordPress admin bar showing when logged out. We included all the possible reasons with step by step instructions.

If any part of this troubleshooting guide is unclear to you, feel free to leave a comment. We will be more than happy to help you to deal with admin bar’s visibility issue.

Team DiviFlash

At DiviFlash, we are more than just a team – we are a collective of Dev Experts, Word Artists, Design Virtuosos, and Marketing Maestros, all united by our profound expertise in Divi and WordPress. Our mission is to provide you with accurate, insightful, and in-depth content aimed at enriching your understanding of Divi, WordPress, and the art of web design.

0 Comments

Submit a Comment

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