-1

In storefront theme, for no result in search page, I would like to show featured products in that view.

So in /storefront/woocommerce/loop/no-product-found.php, i've added this code:

<div class="site-main">
  

<?php echo do_shortcode('[products per_page="10" columns="3"]')?>
</div>

So when i search for something like "shoes",I was hoping wordpress to show no results and then goes on showing the featured products. However, I'm not able to show the featured products.

When I check the query, its partly due to the page is in search where there is a query searching for the product name which is "shoes".

Is there a way to exclude that in any queries for search page? If that makes any sense.

Ruvee
  • 8,611
  • 4
  • 18
  • 44
lilsizzo
  • 366
  • 2
  • 18

1 Answers1

1

The shortcode you tried to use is incorrect.

The shortcode for featured products is:

echo do_shortcode('[featured_products limit="3"]');

Note: you could also pass it a limit.

woocommerce shortcodesDocs


Other related shortcodes:

For products on sale:

echo do_shortcode('[sale_products]');

For popular products:

echo do_shortcode('[best_selling_products]');

For top rated products:

echo do_shortcode('[top_rated_products]');

For recent products:

echo do_shortcode('[recent_products]');

Since you're using storefront theme, it has a 404 page which shows featured products and Popular Products etc. by default! You don't have to change/modify any of its templates. However, if you're overridding storefront with woocommerce templates then you could go ahead and manipulate any template you want using the shortcodes i just gave you!

Ruvee
  • 8,611
  • 4
  • 18
  • 44