Woocommerce 无结果页面无法显示特色产品 [英] Woocommerce no result page not able to show featured products

查看:43
本文介绍了Woocommerce 无结果页面无法显示特色产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在店面主题中,如果搜索页面没有结果,我想在该视图中显示特色产品.所以在/storefront/woocommerce/loop/no-product-found.php,我添加了这段代码

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

因此,当我搜索诸如鞋子"之类的内容时,我希望 wordpress 不显示任何结果,然后继续显示特色产品.但是,我无法展示特色产品.当我检查查询时,部分原因是页面在搜索中,其中有一个查询搜索产品名称鞋子".有没有办法在搜索页面的任何查询中排除它?如果这有任何意义

解决方案

您尝试使用的简码不正确.

特色产品的简码是:

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

注意:你也可以给它一个限制.

<块引用>

woocommerce 简码文档


其他相关短代码:

对于特价商品:

echo do_shortcode('[sale_products]');

对于热门产品:

echo do_shortcode('[best_sales_products]');

对于评分最高的产品:

echo do_shortcode('[top_rated_products]');

对于最近的产品:

echo do_shortcode('[recent_products]');


由于您使用的是 storefront 主题,它有一个 404 页面,其中显示了 Featured productsPopular Products 等默认!您不必更改/修改其任何模板.但是,如果您使用 woocommerce 模板覆盖 storefront,那么您可以继续使用我刚刚给您的简码来操作您想要的任何模板!

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, ive 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

解决方案

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!

这篇关于Woocommerce 无结果页面无法显示特色产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆