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

Last updated: April 1, 2015
Missing WordPress Admin Bar

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.

Share this page


Add a Comment

Back to Top