I have a WordPress problem that I can’t fix….
Woocommerce is using a sidebar with product filters.
I’d simply like to hide the sidebar + filters on Woocommerce parent pages.
I first tried by adding a class which I could hide the sidebar content with css, like this :
add_filter( 'fusion_sidebar_1_class', 'usl_wc_product_cats_css_body_class' );
function usl_wc_product_cats_css_body_class( $classes )
{
if( is_tax( 'product_cat' ) ) {
$cat = get_queried_object();
if( 0 == $cat->parent ) $classes[] = 'usl-parent';
}
return $classes;
}
But this obviously leaves the main content at 80% or so.
So I’m now trying to remove the sidebar instead using a mix of the above and some example code from the Avada help pages. Code is below but totally doesn’t work! Can anyone please help?
function remove_woo_commerce_sidebar() {
global $avada_woocommerce;
{
if( is_tax( 'product_cat' ) )
{
$cat = get_queried_object();
if( 0 == $cat->parent )
remove_action( 'woocommerce_sidebar', array( $avada_woocommerce, 'add_sidebar' ), 10 );
}
}
add_action( 'after_setup_theme', 'remove_woo_commerce_sidebar' );
2
Answers
Couldn't find a neat way to unload the sidebar so added an extra body class so I could target both the main content & sidebar with this :
Can’t you just do this through CSS? Just change the selector to match the page type you want to affect