I am using this below code to remove woocommerce sidebar, from cart and single-product page.

function urun_sidebar_kaldir() {
    if ( is_product() || is_cart() ) {
        remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_action( 'woocommerce_before_main_content', 'urun_sidebar_kaldir' );

It works in single-product page, but it doesn't work cart page.

I can't remove sidebar in cart page.


I am not using woocommerce.php in theme main folder.

And i have this templates in my theme.


I created custom teplate for cart. And i removed get_sidebar(); but sidebar is still displaying in cart page.


2 Answers 2


First, most themes have multiple page templates you can choose from.

Please check:

  1. go to cart page (in wp-admin).
  2. See side metabox 'Page Attributes'.
  3. There you can set the page template, does it have something like 'full_width'?

You can also try a different hook, like wp_head.


add_action( 'wp_head', 'urun_sidebar_kaldir' );

Let me know.

After checking the WOO cart template, i can't find a do_action( 'woocommerce_sidebar' ). It does exist in the singe-product.php template.

Are you certain the cart sidebar is generated by WooCommerce?

Add a full-width template to your theme:

Read this.

Then follow the steps i mentiod at the beginning of my answer.

  • I am developing a new theme. And i tried 'wp_head' and 'init'
    – wpdev
    Jun 9, 2018 at 8:09
  • See my updated answer
    – Bjorn
    Jun 9, 2018 at 8:37
  • It not generated by Woocommerce. I tried remove get_sidebar() from page.php it removed from cart page too. But i wonder, why 'remove_action' working for single-product and not working for cart page.
    – wpdev
    Jun 9, 2018 at 8:45
  • Like i said: do_action( 'woocommerce_sidebar' ) does exist in the singe-product.php template. that's why your remove_action() is working for single products. If the cart sidebar is not generated by WOO, you'll have to find who/what is creating it.
    – Bjorn
    Jun 9, 2018 at 9:30
  • Well that's kinda hard without knowing how you setup everything. Do you override the Woo cart template inside your theme? Does your theme default has a sidebar? Can't you create a no-sidebar template inside your theme?
    – Bjorn
    Jun 9, 2018 at 9:46

For me it works with the following code, but I'm not sure if this is really viable and future proof.

function woo_remove_sidebar() {              
    if( ! is_product() or
        ! is_cart() or
        ! is_checkout() or
        ! is_account_page() )
        remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_filter( 'is_active_sidebar', 'woo_remove_sidebar' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.