Showing Products When No Products Were Found Matching Your Selection

Sometimes customer on your site search product but it can not find specific product or result will be display “No products were found matching your selection.” It may be happen by keyword they used for find product not be specific or your shop doesn’t have this product which they want. So Woocommerce display a meassge like “No products were found matching your selection”. So In this situation, If you want to show some product for the customer when no other products can be found. So here is solution.

Copy below line of code and paste this code at the end of your theme’s functions.php file of your active child theme (or theme) and Save the file. We will show 4 most recent products.

add_action( 'woocommerce_no_products_found', 'show_products_on_no_products_found_matching_selection', 20 );
function show_products_on_no_products_found_matching_selection() {
	echo '

' . __( 'You may be interested in...', 'domain' ) . '

'; echo do_shortcode( '[recent_products per_page="4"]' ); }
Scroll to Top