Site logo

Archived topic

Hide sidebar in woocommerce search results page

5 replies · Started by Daniel on January 12, 2016

Viewing posts 1–6 of 6

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!

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

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?

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

It worked perfectly.
Many thanks!

You're welcome :)

This archived topic is closed to new replies.