Back

Wordpress PHP

How To Offset A Fixed Header When Admin Bar Is Displayed

In your php file, within the header div, add in this code

<div style = 'top:
  <?php
    if(is_admin_bar_showing()){
      echo('30px');
    } else {
      echo('0');
    }
  ?>
'>
</div>

For more flexibility, you can use a css class

.admin-offset {
    top: 46px;
    @media only screen and (min-width: 788px){
      top: 32px;
    }
}