- This topic has 11 replies, 2 voices, and was last updated 7 years, 2 months ago by
Tom.
-
AuthorPosts
-
July 9, 2016 at 9:56 am #207786
Dmitry Bychenko
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?-
This topic was modified 7 years, 2 months ago by
Dmitry Bychenko.
July 9, 2016 at 9:57 am #207789Tom
Lead DeveloperLead DeveloperHi 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; }
July 9, 2016 at 10:37 am #207799Dmitry Bychenko
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
July 9, 2016 at 10:38 am #207800Tom
Lead DeveloperLead DeveloperIf 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
July 9, 2016 at 10:48 am #207801Dmitry Bychenko
that metabox doesnt work too.
what means “is_woocommerce() isn’t true” ?
i’ve installed normal woocommerce plugin from wordpress’es repository
July 9, 2016 at 10:53 am #207802Tom
Lead DeveloperLead DeveloperThat’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?
July 9, 2016 at 11:00 am #207803Dmitry Bychenko
July 9, 2016 at 11:08 am #207805Tom
Lead DeveloperLead DeveloperHmm, 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
July 9, 2016 at 11:48 am #207816Dmitry Bychenko
i put this code in Shop Page’s metabox
July 9, 2016 at 11:49 am #207817Tom
Lead DeveloperLead DeveloperAh that’s the problem, you need to add it like this: https://generatepress.com/knowledgebase/adding-php-functions/
July 9, 2016 at 11:59 am #207822Dmitry Bychenko
yeh, php is not css… 🙂
it’s working with simple php
thanks!
July 9, 2016 at 12:07 pm #207828Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
-
This topic was modified 7 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.