在WooCommerce单一产品页面上显示ACF字段 [英] Display ACF fields on WooCommerce single product page
本文介绍了在WooCommerce单一产品页面上显示ACF字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用ACF创建了一个定制字段,我想在我的WooCommerce单一产品页面中显示它。我如何才能做到这一点?
推荐答案
您需要找出表示应显示acf字段的位置的挂钩,例如,使用单个产品页面的WooCommerce Visual Hook Guide。
示例
add_action( 'woocommerce_after_single_product_summary', 'view_acf_field_for_single_product', 10 );
function view_acf_field_for_single_product(){
if (function_exists('the_field')){
the_field('field_name');
}
}
这是根据https://support.advancedcustomfields.com/forums/topic/acf-with-woocommerce/改编的。
这篇关于在WooCommerce单一产品页面上显示ACF字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文