我在网站上找到了一些代码,用于在类别页面上显示产品属性。这工作正常,它完美地显示了我想要的属性,但是如果我能在产品标题下方而不是按钮下方获得它,那将是非常完美的,就像现在一样。有人可以帮我怎么做吗?
这就是现在的样子
/**
* 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>';
}
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>';
}
在你提到的地方没有钩子。查看此钩子指南以获取更多信息