Remove header from the WooCommerce administrator panel
Asked Answered
K

7

5

Using the storefront theme, I want to remove breadcrumbs when logged in to the administrator panel WooCommerce |Products Store Activity| Inbox| Orders| Stock| Reviews| Notices| breadcrumbs.

Please note this: I need if you are logged in as the current user, not an administrator. The code I used using CSS:

.woocommerce-layout__header-breadcrumbs {
   display: none !important;
}
.woocommerce-layout {
   display: none !important;
}

Screenshot

Kasten answered 2/8, 2019 at 7:31 Comment(3)
It would be better if you add the HTML code as well.Dioptometer
?? didnt get youKasten
You have posted the CSS code that you have tried but what about the HTML associated with it? :) Others cannot verify that the code is right unless they are on the same options setup by you.Dioptometer
H
-1

Add the following code snippet to your active theme's functions.php file -

remove_action( 'in_admin_header', array( 'WC_Admin_Loader', 'embed_page_header' ) );
Hellman answered 2/8, 2019 at 9:35 Comment(1)
There is no any explanation added and this code does not work also.Rhodolite
I
8

As of 28 March 2020, for all users, the following code removes the new Woocommerce Header added into the WordPress Admin. Put the following in your theme's functions.php file:

// Disable WooCommerce Header in WordPress Admin
add_action('admin_head', 'Hide_WooCommerce_Breadcrumb');

function Hide_WooCommerce_Breadcrumb() {
  echo '<style>
    .woocommerce-layout__header {
        display: none;
    }
    .woocommerce-layout__activity-panel-tabs {
        display: none;
    }
    .woocommerce-layout__header-breadcrumbs {
        display: none;
    }
    .woocommerce-embed-page .woocommerce-layout__primary{
        display: none;
    }
    .woocommerce-embed-page #screen-meta, .woocommerce-embed-page #screen-meta-links{top:0;}
    </style>';
}
Incidental answered 27/3, 2020 at 15:20 Comment(1)
Thank you so much for this! The header was so annoying because it was covering my text editor bar at the top so that I had to keep scrolling to the top of the page to change anything.Gastroenterology
D
3

That code would work fine, but the question is where do you use it? The CSS would affect only the frontend while the Admin End has a different style sheet source. You can try adding an Add Admin CSS plugin to post that code or use a custom action like this below in your function.php file:

add_action('admin_head', 'Hide_WooCommerce_Breadcrumb');

function Hide_WooCommerce_Breadcrumb() {
  echo '<style>
    .woocommerce-layout__header-breadcrumbs {
      display: none;
    }
  </style>';
}

Output:

Enter image description here

Dioptometer answered 2/8, 2019 at 9:18 Comment(3)
Thanks a lot for you time.This also works but above answer is more close what i what i am looking forKasten
Cool. Ofcourse you are allowed to choose the better solution but I though you just wanted to remove the Breadcrumbs and not the options on the right. Does his code not hide them too?Dioptometer
So why would you use that solution when you only want to hide the breadcrumbs? :) I just re-framed the question so that the chosen answer syncs well.Dioptometer
N
3

After WooCommerce 5.2, we have to cancel the margin of #wpbody. This code snippet is the revised version of itzmekhokan's and still is active.

add_action( 'admin_head', function (){
  remove_action( 'in_admin_header', array( 'Automattic\WooCommerce\Admin\Loader', 'embed_page_header' ) );
  echo '<style>#wpadminbar + #wpbody { margin-top:0; }</style>';
});

---Addition---

The class name has changed from around version 6.5.

add_action( 'admin_head', function (){
  remove_action( 'in_admin_header', array( 'Automattic\WooCommerce\Internal\Admin\Loader', 'embed_page_header' ) );
  echo '<style>#wpadminbar + #wpbody { margin-top:0; }</style>';
});
Nammu answered 17/4, 2021 at 9:25 Comment(2)
This sounds more correct as the event listener by the loader class should stop searching for "hidden" display none selectors and populate Inbox with crap and so on.Rake
its work for latest woo july 22Outhouse
D
2
function wp_custom_css() {
    echo '<style>
    .woocommerce-embed-page #wpbody .woocommerce-layout, .woocommerce-embed-page .woocommerce-layout__notice-list-hide+.wrap {
        padding-top: 10px;
    }
    .woocommerce-embed-page #screen-meta, .woocommerce-embed-page #screen-meta-links {
        top: 0px;
    }
    .woocommerce-layout__header {
        display: none;
    }
    .woocommerce-layout__activity-panel-tabs {
        display: none;
    }
    .woocommerce-layout__header-breadcrumbs {
        display: none;
    }
    </style>';
}
add_action('admin_head', 'wp_custom_css');
Diactinic answered 15/8, 2020 at 11:30 Comment(2)
This question already contains multiple answers and an accepted answer. Can you explain (by editing your answer) where your answer differs from the other answers? Also know that Code-only answers are not useful in the long run.Meltage
The best solution 2021. This solution also adresses an issue with invalid header size caused by other solutions.Rhodolite
F
0

UPDATED 2020:

function Hide_WooCommerce_Breadcrumb() {
    echo '<style>
    .woocommerce-layout__header {
        display: none;
    }
    .woocommerce-layout__activity-panel-tabs {
        display: none;
    }
    .woocommerce-layout__header-breadcrumbs {
        display: none;
    }
    </style>';
}
Furtive answered 15/3, 2020 at 18:40 Comment(0)
B
0
// Removing the embedded element.
#woocommerce-embedded-root {
  display: none !important;
}
// Removing the empty spacing after removing the embedded element.
#wpbody {
  margin-top: unset !important;
}
Broadwater answered 23/9, 2021 at 23:38 Comment(1)
This might be a good solution, but it found itself in the Low Quality Answers queue for review. Please add some discussion explaining the solution and how it works, to make it more helpful to future readers of this site.Countrywoman
H
-1

Add the following code snippet to your active theme's functions.php file -

remove_action( 'in_admin_header', array( 'WC_Admin_Loader', 'embed_page_header' ) );
Hellman answered 2/8, 2019 at 9:35 Comment(1)
There is no any explanation added and this code does not work also.Rhodolite

© 2022 - 2025 — McMap. All rights reserved.