When I am logged in, there is a gray admin bar on top. My theme layout got distorted by the bar. How to solve the layout problem? Is there a function that can detect user is logged in or not, or use CSS can solve the problem ?
The theme demo is at: http://raptor.hk/dev/theme and below is the screenshot when the gray bar is there.
p.s. I use WordPress 3.2.1
& plugin Theme Test Drive
The top bar of your theme is also positioned absolutely, so it doesn’t know to come down. You can use
is_admin_bar_showing()
to check to see if it’s showing, and then I’d probably just inject some styles usingwp_head
to move it down, since it’s very little CSS.All told, you’d get something in your theme’s
functions.php
like:The admin bar only shows up if you’re logged in. If you don’t like it at the top, you can always move it to the bottom. Add this to your theme’s functions.php file:
To hide the admin bar paste this function into function.php
Add this into functions.php :
This is default callback for the admin bar from
wp-includes/admin-bar.php
:It seems as while the other answers do work, the clean and intended way to do this according to WordPress Core Code is this: