Personal Tech Blog documenting problems and solutions, mainly for C# programming in .NET and Blogger Template Customizations.

WordPress : How to solve missing Admin Bar at the top of the page

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
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 :

  1. 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.

  2. Missing wp_footer function

    Footer template footer.php should call the wp_footer function. It should be located just before the closing body tag like this:

  3. PHP Syntax Error

    If you located both the get_footer and 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 get_footer() or 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

Comments

  • What an awesome post!

    I had installed Admin Bar Disabler plugin to deacitvate my WordPress admin bar and when I deactivated and removedthat plugin, my admin bar was disappereed.

    I was confused.How did this happen?

    Then, thank god I got your amazing post which helped me in solving my problem.

    My wp_footer function was missing.Actually,that admin bar disabler plugin deleted my wp_footer function I guess.

  • Had the same problem, tried a lot of suggestions, but then I found out there was a white line in the header. Removing the white line did the job.

Leave a Reply

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

CommentLuv badge

Back to Top