doukanxi4246 2017-07-27 00:56
浏览 131

Woocommerce如何在目录页面上的产品标题下显示产品属性?

I have a WordPress, WooCommerce based shop and I was wondering how can I display product attributes under product title on catalog page?

I guess it's just a filter needed to add, but how can I grab the values of the attributes of each product?

Thanks in advance to everyone who tries to help, Have a great day =)

  • 写回答

1条回答 默认 最新

  • doubi1910 2017-07-27 04:53
    关注

    According to your query i can to use on wc_get_product_terms() method for this case as

    in the products loop use

    global $product;
    $colors = array_shift( wc_get_product_terms( $product->id, 'pa_color', array( 'fields' => 'names' ) ) );
    

    Otherwise

    global $product;
    $colors = $product->get_attribute( 'pa_color' );
    

    OR using get_post_meta wp machanism as

    $pa_color = get_post_meta($product->id, 'pa_color', true);
    

    So use ,what are you want from above.

    Thank you

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大