Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce - How to remove sidebar

I need to remove sidebar into my woocommerce store. I have tried with backend in option theme and in each category but resultless.

I tried also:

1.file wp-template-hooks.php removed--> do_action(..

2.file archive-product.php removed--> do_action(..

  1. insert in file function.php in theme dir and function.php in woocommerce dir remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );

  2. into database there is 2 tables with 2 fields serialised but is a risk change this.

resulless.

I finished the ideas. Where is saved into db the visibility of sidebar? or the variable?

Can you help me?

Thanks Ale

like image 583
Alessandro Gnola Avatar asked Feb 26 '16 12:02

Alessandro Gnola


2 Answers

I just wanted to update this post for WooCommerce version 3.2.3 - 2017

OK the WooCommerce Plugin includes a folder with all the template files if you want to make changes to the template on a custom theme or child theme you need to copy all of the desired template into a folder called woocommerce in your root theme folder. This will overwrite the plugin templates and will allow for WooCommerce updates with overwriting your custom changes. These templates have all of the do_actions and hooks in the comments so it makes it easy to understand how it's working.

That said WooCommerce has hooks that allow for you to add or remove blocks of code you can check out the API Docs here.

To remove the side bar you need to add this into your functions.php file in your theme setup function

remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
like image 164
DevTurtle Avatar answered Oct 06 '22 00:10

DevTurtle


Please, add this code to your functions.php

function mb_remove_sidebar() {
    return false;
}

add_filter( 'is_active_sidebar', 'mb_remove_sidebar', 10, 2 );
like image 33
Maksim Borodov Avatar answered Oct 06 '22 01:10

Maksim Borodov