Archived topic
Settings to turn off Sidebar on Woocommerce's page Shop
11 replies · Started by Dmitry Bychenko on July 9, 2016
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
If that's not working, it means is_woocommerce() isn't true.
Try the metabox on the page instead: https://generatepress.com/knowledgebase/choosing-sidebar-layouts/#metabox
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?
Hmm, that code should work.
How/where are you adding the code in this post?: https://generatepress.com/forums/topic/settings-to-turn-off-sidebar-on-woocommerces-page-shop/#post-207789
i put this code in Shop Page's metabox
Ah that's the problem, you need to add it like this: https://generatepress.com/knowledgebase/adding-php-functions/
yeh, php is not css... :)
it's working with simple php
thanks!
You're welcome :)
