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.

    • Will

    • January 14, 2014 at 4:24 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.