简体   繁体   中英

how to display ACF select field(drop down) in my website product add page?

I'm using ACF select field to add my locations to website. I create a ACF but I need to display that field on my web site. I used the_field('plocation'); option to display it but its not working. Is there any other option to display my custom field in my product add page its really helpful. Please help me I'm stuck in this problem 1 week. I put some screenshot my problem.

This is the my ACF setting这是我的 ACF 设置

Where I need this field我需要这个字段的地方

I'm really appreciate your help thank you so much, ashen.

Guys i found a method a to show acf select field values in a drop down box here is the code

hope some one help this...

Code goes the child theme funtion.php

add_action( 'dokan_new_product_after_product_tags','new_product_field',5);
function new_product_field(){ 

$field_key = "field_601141959f1ad";
        $field = get_field_object($field_key);

        if( $field )
        {
            echo '<div class="acf-task-difficulty-values">';
echo'<select class="dokan-form-control" name="plocation">';
echo'<option value="0">&#8211;Select a location&#8211</option>';
                foreach( $field['choices'] as $k => $v )
                {

                   
              echo'<option class="level-0" value=.'.$k.'>' . $v . '</option>';
                }
echo'</select>';
            echo '</div>';echo"<br>";
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM