Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] No sidebar on product page

Home Forums Support No sidebar on product page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #184952
    MaksymPS

    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 😉

    #185094
    Tom
    Lead Developer
    Lead Developer

    In your PHP code, change both-left to no-sidebar.

    #185363
    MaksymPS

    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).

    #185384
    Tom
    Lead Developer
    Lead Developer

    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;
    
     }
    #185850
    MaksymPS

    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 🙂

    #185926
    Tom
    Lead Developer
    Lead Developer

    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/

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.