我正在开发一个项目,我想在其中显示来自 Woocommerce 的产品图像和海关属性。
我已经设置了这样的属性
我想在我的 php 代码中显示所有属性(标题和术语)。
我已经尝试过 <?php $product->list_attributes(); ?>
。它工作正常,但数据显示在 <table>
中。我想自定义显示。
感谢您的帮助!
最佳答案
每当我在 WooCommerce 中遇到这样的自定义方法时,我都会尝试诉诸 the docs看看发生了什么。
如果您inspect the source对于此方法,您会发现它实际上使用自定义模板 single-product/product-attributes.php
来输出您所看到的此表。
为了更改输出,您有两种选择:
- Override the template via your theme
- 观察
single-product/product-attributes.php
并使用其中的信息在原始模板中编写您自己的自定义循环。
第二个选项意味着您可能会使用 get_attributes()
方法,而不是 list_attributes()
。
关于woocommerce - 显示所有自定义属性 Woocommerce,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33391960/