ACF 字段未显示在产品标签上

ACF Fields not displaying on Product Tag

我已将 ACF 添加到我们现有的网站,该网站使用高度自定义的子主题。

在我的新字段组中,我将位置规则设置为 Post 分类法,它等于 product_tag 值(“经典”)。但是,这些自定义字段未显示或不存在。

我认为可以通过“屏幕选项”启用自定义字段,但是 product_tag 分类页面上没有屏幕选项。

我还禁用了除 elementor、ACF 和 woocommerce 之外的所有插件。同样的结果。

关于如何解决这个问题有什么想法吗?

我能够创建一个解决方案,通过 functions.php 将自定义元添加到 woocommerce 产品标签和类别。

add_action('product_tag_add_form_fields', 'dr_taxonomy_add_new_meta_field', 10, 1);
add_action('product_tag_edit_form_fields', 'dr_taxonomy_edit_meta_field', 10, 1);

//Product Tag Create page
function dr_taxonomy_add_new_meta_field() {
    ?>   
    <div class="form-field">
        <label for="dr_elementor_template"><?php _e('Elementor Shortcode', 'wh'); ?></label>
        <input type="text" name="dr_elementor_template" id="dr_elementor_template">
    </div>
    <?php
}

//Product Tag Edit page
function dr_taxonomy_edit_meta_field($term) {
    $term_id = $term->term_id;
    $dr_elementor_template = get_term_meta($term_id, 'dr_elementor_template', true);
    ?>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="dr_elementor_template"><?php _e('Elementor Shortcode', 'wh'); ?></label></th>
        <td>
            <input type="text" name="dr_elementor_template" id="dr_elementor_template" value="<?php echo esc_attr($dr_elementor_template) ? esc_attr($dr_elementor_template) : ''; ?>">
        </td>
    </tr>
    <?php
}

add_action('edited_product_tag', 'dr_save_taxonomy_custom_meta', 10, 1);
add_action('create_product_tag', 'dr_save_taxonomy_custom_meta', 10, 1);

// Save extra taxonomy fields callback function.
function dr_save_taxonomy_custom_meta($term_id) {
    $dr_elementor_template = filter_input(INPUT_POST, 'dr_elementor_template');
    update_term_meta($term_id, 'dr_elementor_template', $dr_elementor_template);
}

与分类关联的分类术语 slug 可以是:Post 类别 => 类别,Post 标签 => post_tag,WC 产品类别 => product_cat, WC 产品标签 => product_tag