How to Remove Sidebar?

A sidebar in WordPress is referred to a widget-ready area used by WordPress themes to display information that is not a part of the main content. It is not always a vertical column on the side. It can be a horizontal rectangle below or above the content area, footer, header, or anywhere in the theme.

Remove Sidebar from Woocommerce Category Page

To remove sidebar from product archives page you need to add the following lines of code in your theme's functions.php file. 

add_filter( 'body_class', 'remove_sidebar' );
 function remove_sidebar()
  {
      if( is_product_category()) 
      { 
         remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
       }
   }

Remove Sidebar form Woocommerce Cart, Checkout and Single Product Page

To remove sidebar from cart, checkout and single product or product detail page you need to add the following lines of code in your theme's functions.php file. 

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

 

Join our Newsletter

Never miss the latest offers, voucher codes and useful articles delivered weekly in your inbox.