Get product custom attributes to display them in WooCommerce product loop(获取产品定制属性以在WooCommerce产品循环中显示它们)
问题描述
我在WooCommerce网站(房地产)工作,我不能在我的首页上显示产品定制属性(例如。平方米、房间、厕所等)。我正在尝试使用下面的代码,但我可以让它工作。使用我拥有的代码,我只能显示产品ID,但当我将属性ID放入代码中时,它只显示单词&或数组。
这是我的代码:
add_action('woocommerce_after_shop_loop_item_title', 'cstm_display_product_category', 5);
function cstm_display_product_category()
{
global $product;
$productAttribute = $product->get_id();
//if(isset($productAttribute)){
echo '<div class="items" style="color: #fff;"><p>Output: ' . $productAttribute . '</p></div>';
/