skip to Main Content

Modify the WooCommerce Search Results 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 to customize the layout of your WooCommerce search results but keep your main shop page and archives using the same layout as defined in the customizer you will need to use a little code to conditionally set the layout of the search results and you can do so using the following snippet.

/**
 * Modify the WooCommerce Search Results Layout.
 *
 * @link https://total.wpexplorer.com/docs/snippets/woo-search-layout/
 * @param string $layout full-width, left-sidebar, right-sidebar
 */
add_filter( 'wpex_post_layout_class', function( $layout ) {
	if ( function_exists( 'is_woocommerce' ) && is_woocommerce() && is_search() ) {
		return 'right-sidebar';
	}
	return $layout;
} );
All PHP snippets should be added via child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)
Back To Top