【问题标题】:How to show only certain data in the woocommerce product page shortcode如何在 woocommerce 产品页面短代码中仅显示某些数据
【发布时间】:2015-02-25 17:02:30
【问题描述】:

我想使用产品页面短代码将 woocommerce 产品添加到我的 wordpress 帖子中。我想展示的只是标题、产品图片和简短描述,而不是整个产品页面。有什么办法可以做到这一点?
http://docs.woothemes.com/document/woocommerce-shortcodes/#section-11

【问题讨论】:

    标签: wordpress woocommerce shortcode


    【解决方案1】:

    产品简码包括content-product.php - 这为您提供了多种选择。您可以:

    1. Override this template with your on template by copying it to your theme folder
    2. 或者您可以取消一些加载页面各个部分的操作。例如,如果您想删除评分标签,可以使用 remove_action(),如下所示:

    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );

    所有钩子的完整列表可以在woocommerce/includes/wc-template-hooks.php中找到

    请注意,这些操作中的任何一个都将影响所有产品年龄,而不仅仅是使用短代码呈现的那些。如果您想更改只是通过简码呈现的页面,那么最好的办法是根据需要复制和编辑模板(根据上面的选项 1),但将其保存在您的主题文件夹中,并使用不同的名称(类似content-product-short.php)。然后创建您自己的短代码函数来获取您的新模板 - 查看 class-wc-shortcodes.php 中的函数以了解想法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-08
      • 1970-01-01
      • 2017-12-20
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      • 2020-01-03
      • 2021-02-09
      相关资源
      最近更新 更多