Remove the sidebar from WooCommerce pages on Storefront

If you are using WordPress/Woocommerce for your shop and using Storefront theme, So you notice all of your Woocommerce pages will have sidebar on all the page e.g. shop, category, product etc.

There is no way to remove those from setting unless you manually remove those or use any plugin for that. But you can remove it by using below code in functions.php (of child theme if you are using).


add_action( 'get_header', 'remove_storefront_sidebar' );
function remove_storefront_sidebar() {
if ( is_woocommerce() ) {
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
}
}

Now, open your theme(child theme’s) style.css in the same location and add this code:

body.woocommerce #primary.content-area {
float: none;
width: 100%;
}

Now, all your WooCommerce pages won’t have a sidebar.
Sidebar removed from all the page now. If you want it to remove only from specific page then you can update the condition is_woocommerce() to below

Main Shop Page

is_shop()

Woocommerce Product Category Page

is_product_category() for specific category is_product_category( 'shirts' )

Woocommerce Product Page

is_product()

If you want to learn more about conditional tags then you can check on Woocommerce Conditional Tags.

Leave a Reply

Your email address will not be published. Required fields are marked *