Does anyone know how to include the admin bar in a page template where wp_head() and wp_footer() are not present? I'm developing a template other scripts and styles are just getting in the way. Rather than go through and dequeue all of the stuff I don't need, I've simple removed the two hooks altogether. All I want instead is the admin bar.


  • Admin bar is printed in the wp_footer(). javascript and style files needed by the admin bar are enqueued in wp_head() (or in wp_footer() if the enqueue order has been modified by a plugin/theme). Not sure if you can easily do what you are trying. – cybmeta Sep 5 '14 at 20:34

From Codex:

<?php show_admin_bar( $bool ); ?>
| improve this answer | |
  • You should explain why this fix the problem. If you try to do it you will notice that your answer is not the answer. That function set the status of the admin bar but not print it. – cybmeta Sep 5 '14 at 20:23
  • I have to agree with this comment. This would only work if it was disabled and wp_head() and wp_footer() existed in my code. Thanks for answering though. – jamil Sep 8 '14 at 17:35

I think you can get it to work by calling the action that renders the bar in your template like this:

<?php do_action( 'wp_footer','wp_admin_bar_render' ); ?>
| improve this answer | |
  • What should that do? do_action() doesn't take the callback as parameter. – fuxia Jun 4 '19 at 19:34
  • It renders only the HTML and include CSS and js for the admin bar. As I can see in line 465 of wp-includes/plugin.php shown in the documentation it will execute the filter associated with that specific action of the footer. developer.wordpress.org/reference/functions/do_action Btw, I tested it myself since I had this issue it worked fine. – René Cum Jun 5 '19 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.