Categories
blog ecommerce Storefront WooCommerce wordpress

WooCommerce Storefront Child Theme: Remove Sidebar @ Single Product Page

Hide the sidebar on product pages of Woocommerce Storefront child theme. The following snippet disables the sidebar with no additional CSS required, whilst still making the product page content area 100% wide.

/**
 * Disable sidebar on product pages in Storefront.
 *
 * @param bool $is_active_sidebar
 * @param int|string $index
 *
 * @return bool
 */
function product_remove_sidebar( $is_active_sidebar, $index ) {
	if( $index !== "sidebar-1" ) {
		return $is_active_sidebar;
	}
if( ! is_product() ) {
return $is_active_sidebar;
}

return false;
}

add_filter( 'is_active_sidebar', product_remove_sidebar', 10, 2 );

 

code to the functions.php file in your Storefront child theme.