Saturday, 12 October 2019

Removing the WooCommerce sidebar the correct way - TwentySeventeen?

I'm working on a project that is running of a child theme of TwentySeventeen and whilst the rest of the site doesn't have a sidebar, WooCommerce seems to have it.

For example, the shop page has it - I have tried a few things already and none work without caveats or didn't work at all:

I tried copying archive-product.php to my theme dir in woocommerce/archive-product.php and removing the below:

do_action( 'woocommerce_after_main_content' );

This didn't work.

I then tried doing:

remove_action('woocommerce_sidebar','woocommerce_get_sidebar',10);

...this didn't work either.

I found this answer and it worked, but didn't make the page full width (still had space for the sidebar) and a comment on the answer noted using that method isn't a great idea.

I also found this answer but it involves adding CSS, something I'd like to avoid as it isn't the most robust method in-case class names change in the future etc...

Isn't there a proper way of doing this without potential side affects?



from Removing the WooCommerce sidebar the correct way - TwentySeventeen?

No comments:

Post a Comment