Archived topic
No sidebar on product page
5 replies · Started by MaksymPS on April 7, 2016
Hi Tom,
Can you help, please, how to hide sidebar from product page?
I use next php code from here:
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 'both-left';
// Or else, set the regular layout
return $layout;
}
In Customizing I set:
Sidebar Layout - Content (No sidebars);
Blog Sidebar Layout - Content (No sidebars);
Single Post Sidebar Layout - Content (No sidebars).
It works, I don't have any sidebars except shop-page, and I'd like to hide sidebar from product-page.
Best regards ;)
In your PHP code, change both-left to no-sidebar.
I meant something else :)
I want to see widget on shop page, but I don't want see it on product page (and in general I don't want to see widgets on other pages).
You could try..
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() && ! is_single() )
return 'both-left';
// Or else, set the regular layout
return $layout;
}
Fatal error:
Fatal error: Cannot redeclare generate_custom_woocommerce_sidebar_layout() (previously declared in .../wp-content/themes/generatepress/functions.php:659) in .../themes/generatepress/functions.php on line 700
Ok, Tom, I added new buttons into a widget and it looks great. Now I don't need in anymore.
Thanks for help :)
Make sure you 1) Don't add the function twice and 2) use these instructions for adding PHP so you don't lose edits while updating: https://generatepress.com/knowledgebase/adding-php-functions/
