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 get_footer function.

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 :

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

  2. Missing wp_footer function

    If the problematic template is not missing get_footer function then look inside Footer template (footer.php) to check if it is calling wp_footer function from there. It should be located just before the closing body tag like this:

    <?php wp_footer(); ?>
    </body>
    </html>
    
  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 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.

One thought on “WordPress : How to solve missing Admin Bar at the top of the page

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

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge