WordPress Snippets at WPcustoms

Disable 28px admin bar push down

The WordPress admin bar inserts a margin-top: 28px into your header. This can cause problems with fixed positioned layouts. This function removes that extra css.


/**
 * Snippet Name: Disable 28px admin bar push down
 * Snippet URL: https://wpcustoms.net/snippets/disable-28px-adminbar-push-down/
 */
  add_action('get_header', 'remove_adminbar_pushdown');

  function remove_adminbar_pushdown() {
    remove_action('wp_head', '_admin_bar_bump_cb');
  }