Home Forums Front-end Issues Display Dropdown list selected value ?


Display Dropdown list selected value ?

  • Hi there.
    I am using ACF to create a dropdown list field for the wordpress admin to select a value among 2 for each woocommerce product.
    That part is ok, but I want to show only the selected value on the front end of each product page.
    In functions.php, I tried something like
    $color = get_field('vente_location');
    but it failed.
    Thanks for any help!

  • It is okay for me, the “_” was the main problem.
    then, to show the value I had to use that kind of code!

    $field = get_field_object('ventelocation');
    $value = get_field('ventelocation');
    $color = $field['choices'][ $value ];
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.