在 WooCommerce 单个产品页面上显示 ACF 字段
Display ACF fields on WooCommerce single product page
我使用 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/。
我使用 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/。