Support » Fixing WordPress » How to test if admin bar is visible

  • Hi,

    Currently I am testing like so:

    global $user_ID; if($user_ID && current_user_can('level_10')) {
    	// do something

    But I want to catch the any admin bar (including for editors etc etc) since I need to adjust the css of my page otherwise content goes under the bar.

    Thanks for any help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator kmessinger


    Is you site live? You can check here,

    Thanks but you misunderstand, I need to check if its being used at the pre-processor (pre-display) point so I can perform some additional logic before the page is displayed.

    if ( is_admin_bar_showing() ) { ... }

    that should do it!


    A simple and easy way to hide your admin bar no plugin needed remove admin bar, find it useful

    merajneesh —

    i think they were asking how to test for whether the bar was showing and adjust the display accordingly — not remove the admin bar.

    Hi havahula–

    what i see is he is trying to test by placing some code in top of page , which is going below admin bar , so its better to remove it .

    I have 2 wrappers for a dynamic layout (fixed top bar + fixed bottom bar). Maybe this example helps:

    <body <?php body_class(); ?>>
    	<div id="wrapper_top">
    	<div id="wrapper_bottom"<?php if(is_admin_bar_showing()) echo ' style="bottom: 28px;"'; ?>>
    	<div id="container">

    Otherwise the distance from the bottom ist 0px (in style.css)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to test if admin bar is visible’ is closed to new replies.