Site logo

Archived topic

Settings to turn off Sidebar on Woocommerce's page Shop

11 replies · Started by Dmitry Bychenko on July 9, 2016

Viewing posts 1–12 of 12

hi guys,

im trying to turn off Sidebar on Woocommerce's page Shop.

I use the code

add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' );
function generate_custom_woocommerce_sidebar_layout( $layout )
{
// If we are on a woocommerce page, set the sidebar
if ( is_woocommerce() )
return 'no-sidebar';

// Or else, set the regular layout
return $layout;

}

as it is said on https://generatepress.com/knowledgebase/choosing-sidebar-layouts/#sidebar-filter
but Sidebar is still there.
What im doing wrong, how to turn it off?

Hi there,

No need to add "Shop" in the is_woocommerce() call.

Your code would be:

add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' );
function generate_custom_woocommerce_sidebar_layout( $layout )
{
 	// If we are on a woocommerce page, set the sidebar
 	if ( is_woocommerce() )
 	 	return 'no-sidebar';

 	// Or else, set the regular layout
 	return $layout;

 }

yes, i just tried to write Shop because

add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' );
function generate_custom_woocommerce_sidebar_layout( $layout )
{
// If we are on a woocommerce page, set the sidebar
if ( is_woocommerce() )
return 'no-sidebar';

// Or else, set the regular layout
return $layout;

}

doesnt work. Sidebar is still there

that metabox doesnt work too.

what means "is_woocommerce() isn’t true" ?

i've installed normal woocommerce plugin from wordpress'es repository

That's a conditional in WooCommerce, it return either true or false depending on if you're on a woocommerce page.

If that code isn't working, it means it's returning false.

Can you link me to the page you're trying to change the sidebar on?

yeh, php is not css... :)

it's working with simple php

thanks!

You're welcome :)

This archived topic is closed to new replies.