Support

Account

Home Forums Front-end Issues get_field not working with select

Solved

get_field not working with select

  • Hello,

    I have a simple select field, user can only select one option.

    In my template, if I use “the_field(‘field_name’)” then the correct selection is displayed.

    But if I use “$withlink = get_field(‘field_name’)” and then echo out the variable, it will only display the first option in the select list, no matter which one is selected.

  • Hi @deeve007

    I can’t reproduce that. Both versions output the selected item and the selected item only.

    Do you see the incorrect value when you debug all fields?

    <?php 
    $fields = get_fields();
    echo "<pre>";
    print_r($fields);
    echo "</pre>";
    ?>

    When you edit the post again, is the first value selected or the one you thought you’d selected?

  • I moved onto radio button, didn’t have time to debug with a very quick/low paying job. Radio button worked as expected with same code as used above.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘get_field not working with select’ is closed to new replies.