在产品标题下方的Woocommerce中显示产品属性

时间:2019-02-06 08:41:12

标签: woocommerce attributes

我在网站上找到了一些代码,可以在类别页面上显示产品属性。效果很好,它可以完美显示我想要的属性,但是如果我可以将其设置在产品标题的下方,而不是按钮的下方(如现在),那将是完美的。有人可以帮我怎么做吗?

this is how it looks now

 /**
 * PPM
 */
add_action( 'woocommerce_after_shop_loop_item', 'acf_template_loop_product_meta', 20 );
function acf_template_loop_product_meta() {
    global $product;

    // Check that we got the instance of the WC_Product object, to be sure (can be removed)
    if( ! is_object( $product ) ) { 
        $product = wc_get_product( get_the_id() );
    }

    echo '<h4>Afdruksnelheid: ' . $product->get_attribute('pa_afdruksnelheid') .' PPM</h4>';

}

1 个答案:

答案 0 :(得分:0)

add_action( 'woocommerce_before_shop_loop_item_title', 'custom_before_title' );
function custom_before_title() {

global $product;

    // Check that we got the instance of the WC_Product object, to be sure (can be removed)
    if( ! is_object( $product ) ) { 
        $product = wc_get_product( get_the_id() );
    }

    echo '<h4>Afdruksnelheid: ' . $product->get_attribute('pa_afdruksnelheid') .' PPM</h4>';


}

您刚才提到的位置没有钩子。选中此join以获取更多信息

相关问题