Recently I was working on my WordPress site and after a while I noticed that the Admin Bar at the top of the page was missing. The Admin panel was still accessible through /wp-admin/ URL and the Admin Bar was not broken inside the Dashboard.
In this post I will show you why this happens and how to bring that Bar back.
This is how that Admin Bar appeared on my site. It completely disappeared. The space for it was still there, it was just empty, not showing anything at all.
Missing Admin Bar at the top of the page
First I tried to identify what exactly caused this problem. I suspected it had to do with my recent template modifications so I temporarily switched to different Theme to see what happens. And sure thing the Admin Bar was not blank and worked perfectly on that template.
Next step was to figure out where Admin Bar gets generated. It turned out to be in the footer template that gets included when
get_footer function is called.
Solution of the problem
So to fix this, we need to check for the following things in the templates by going to Appearance > Editor :
Missing get_footer function
First we need to check if
get_footer function is not missing in the templates. Open the template file causing the problem. For example if the admin bar is missing in pages but not in posts, look into Page Template
page.php. If you are not familiar with the WordPress templates, check WordPress Template Hierarchy for more information.
When the problematic template is located, there should be code like this at the end of the file:
Note:Not all template files need
get_footer(). If template has in the beginning
get_header() it usually should have
get_footer() at the end of the template.
If the problematic template is not missing
get_footer function, maybe the problem is with the Footer template itself. This is covered in the next step.
Missing wp_footer function
footer.php should call the
wp_footer function. It should be located just before the closing body tag like this:
<?php wp_footer(); ?>
PHP Syntax Error
If you located both the
wp_footer functions, then there is a possibility that the code execution was stopped due to some PHP syntax error and it never reached either the
wp_footer() line. I check for PHP errors by temporally putting echo statements inside templates to test where in the code does the execution stops.
Culprit of my problems was the last case. There were PHP errors just before the
get_footer() call, so the whole template was generated but the last few lines of code were never executed.
I hope this post will help others in similar situations. If you are aware of some other way that causes this problem, let me know and I will add it to the list.
Last Updated: 1st April 2015