0

I'm working on a WP site which has a custom theme built from scratch and I can't seem to figure out how to get the Admin Bar to appear when viewing the public site.

The themes footer.php file has the wp footer code in it: <?php wp_footer(); ?> just before the closing </body> tag. I've tried disabling all plugins and reverting back to default theme. The Admin bar appears when using the Twenty Twenty One theme so the issue is with this custom built theme for sure. Disabling plugins had no effect.

The theme is using ACF.

I have enabled admin bar from my WordPress profile settings.

WP_DEBUG doesn't throw any errors or notices.

How could I troubleshoot this further?

2
  • Please see this link. Problem looks exactly the same as yours.
    – SagarG
    Feb 17, 2021 at 8:24
  • Thank you! The solution in this link is better than the one I found because it actually checks if the user is logged in Feb 17, 2021 at 9:04

1 Answer 1

0
add_filter( 'show_admin_bar', '__return_true');

Add this at the end of functions.php

4
  • Adding it like that did not work but you pointed me in to right direction and I found the solution from the WP Code Reference page: link The correct solution was to add add_filter( 'show_admin_bar', '__return_true'); to my functions.php file. If you want to change that to your answer I'll accept it as solution :) Feb 17, 2021 at 8:59
  • glad you figured it out :) I will update the answer so it may be helpful for someone else.
    – MMK
    Feb 17, 2021 at 9:01
  • Actually that added the admin bar to the public site even if the user was not logged in. There was a better solution which checks if user is logged in, found here: link Feb 17, 2021 at 9:08
  • yes, you can apply check over the filter depending upon the requirements.
    – MMK
    Feb 17, 2021 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.