ACF 分类字段值未在后端选择

时间:2021-02-02 08:26:09

标签: php advanced-custom-fields taxonomy custom-taxonomy taxonomy-terms

我使用 ACF 分类法创建了交付类型字段。它工作正常(检查 screenshot 1),但我需要在我的网站产品添加页面中添加此字段。

我在我的主题 funtion.php 中使用了一些硬代码来显示产品添加页面中的交付类型字段。

这是代码-

<div>
Please enter Delivery Type "Free Of Delivery Or Delivery charges Apply"

</div>
//dtype
 <?php if ( dokan_get_option( 'product_category_style', 'dokan_selling', 'single' ) == 'single' ): ?>
                                    <div class="dokan-form-group">

                                        <?php
                                        $selected_dtype  = dokan_posted_input( 'delivery_types' );
                                        $dtype_args =  array(
                                            'show_option_none' => __( '- Select a Delivery types  -', 'dokan-lite' ),
                                            'hierarchical'     => 1,
                                            'hide_empty'       => 0,
                                            'name'             => 'delivery_types',
                                            'id'               => 'delivery_types',
                                            'taxonomy'         => 'delivery_types',
                                            'title_li'         => '',
                                            'class'            => 'product_cat dokan-form-control dokan-select2',
                                            'exclude'          => '',
                                            'selected'         => $selected_dtype  ,
                                        );

                                        wp_dropdown_categories( apply_filters( 'dokan_product_cat_dropdown_args', $dtype_args ) );
                                        ?>
                                    </div>

                                <?php elseif ( dokan_get_option( 'product_category_style', 'dokan_selling', 'single' ) == 'multiple' ): ?>
                                    <div class="dokan-form-group">
                                        <?php

                                        include_once DOKAN_LIB_DIR.'/class.taxonomy-walker.php';

                                        $selected_dtype  = dokan_posted_input( 'delivery_types', true );
                                        $selected_dtype  = empty( $selected_dtype  ) ? array() : $selected_dtype  ;

                                        $drop_down_dtype = wp_dropdown_categories( apply_filters( 'dokan_product_cat_dropdown_args', array(
                                            'show_option_none' => __( '', 'dokan-lite' ),
                                            'hierarchical'     => 1,
                                            'hide_empty'       => 0,
                                            'name'             => 'delivery_types[]',
                                            'id'               => 'delivery_types',
                                            'taxonomy'         => 'delivery_types',
                                            'title_li'         => '',
                                            'class'            => 'product_cat dokan-form-control dokan-select2',
                                            'exclude'          => '',
                                            'selected'         => $selected_dtype,
                                            'echo'             => 0,
                                            'walker'           => new TaxonomyDropdown()
                                        ) ) );

                                        echo str_replace( '<select', '<select data-placeholder="'.esc_attr__( 'Select Delivery types', 'dokan-lite' ).'" multiple="multiple" ', $drop_down_dtype ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
                                        ?>
                                    </div>
                                <?php endif; ?>

但问题是它没有保存在后端。(检查 screenshot 1

我的 ACF 设置

检查Screenshot 2

检查screenshot 3

如果有人能帮助我真的很感激,因为我在这个问题上陷入了一个多月的困境。

谢谢。

0 个答案:

没有答案
相关问题