Snippets: WooCommerce Search Results Custom Layout

The WooCommerce search results page uses the same search template as all the shop archives which you can alter at Appearance > Customize > WooCommerce (Total) > Shop & Archives > Layout.

Now, if you need the search to have a sidebar but NOT your main shop page, shop categories/tags then you can add this code to your site to alter the layout conditionally.

add_filter( 'wpex_post_layout_class', function( $layout ) {

	if ( function_exists( 'is_woocommerce' ) && is_woocommerce() && is_search() ) {
		return 'right-sidebar'; // or left-sidebar

	return $layout;
} );
All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)