Ready to get started?Download WordPress


How to test if admin bar is visible (8 posts)

  1. ferahl
    Posted 3 years ago #


    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

  2. kmessinger
    Posted 3 years ago #

    Is you site live? You can check here, http://browsershots.org/

  3. ferahl
    Posted 3 years ago #

    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.

  4. havahula
    Posted 3 years ago #

    if ( is_admin_bar_showing() ) { ... }

    that should do it!

  5. merajneesh
    Posted 3 years ago #


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

  6. havahula
    Posted 3 years ago #

    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.

  7. merajneesh
    Posted 3 years ago #

    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 .

  8. _az_
    Posted 2 years ago #

    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)

Topic Closed

This topic has been closed to new replies.

About this Topic