[Resolved] Hide sidebar in woocommerce search results page

Home Forums Support [Resolved] Hide sidebar in woocommerce search results page

Home Forums Support Hide sidebar in woocommerce search results page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #165223
    Daniel

    Hi there!

    I was using Generate Press 1.3.2.1 in a woocommerce store and the woocommerce search results page didn’t have a sidebar.
    I updated to 1.3.2.3 and the sidebar is showed in woocommerce search results.

    How can I hide it again?

    Thanks!

    #165350
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Give this function a 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() )
     	 	return 'no-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    I’ll be adding this as an option in the Customizer soon πŸ™‚

    #165403
    Daniel

    The sidebar seems to dissapear but the width of the div has this class applied:
    .masonry .grid-sizer, .masonry .masonry-post {
    width: 33.333%;
    }
    so it doesn’t fill the full width. I suppose I can change it using css but is there another workaround?

    #165473
    Tom
    Lead Developer
    Lead Developer

    Ah, you may have to disable masonry for WooCommerce.

    add_filter('generate_blog_masonry','generate_blog_woocommerce_masonry');
    function generate_blog_woocommerce_masonry()
    {
    	// Disable in WooCommerce
    	if ( is_woocommerce() )
    		return 'false';
    
    	// Check if blog
    	if ( is_home() )
    		return 'true';
    	
            // Otherwise, disable it
    	return 'false';
    }

    Let me know if that helps or not πŸ™‚

    #165478
    Daniel

    It worked perfectly.
    Many thanks!

    #165591
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

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