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.
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
Solution of the problem
So to fix this, we need to check why
get_footer function is not getting executed. It could be from different reasons.
Check for the following things in your Template by going to Appearance > Editor :
Missing get_footer function
First we need to check if
get_footerfunction is not missing in the templates. Open the template file causing the problem and check at the end of the file if there is code like this:
<?php wp_footer(); ?>
Note:Not all template files need
wp_footer(). If template has in the beginning
wp_header()it usually should have
wp_footer()at the end of the template. For more information check WordPress Template Hierarchy.
Missing wp_footer function
If the problematic template is not missing
get_footerfunction then look inside Footer template (footer.php) to check if it is calling
wp_footerfunction from there. It should be located just before the closing body tag like this:
<?php wp_footer(); ?> </body> </html>
PHP Syntax Error
If you located both the
wp_footerfunctions, then there is a possibility that the code execution was stopped due to some PHP syntax error and it never reached the
get_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.